Thursday, May 2, 2013

Hot deploy in R1

ADF Release 1 of jdeveloper has limited support for hot deploying java code.  When running the integrated Weblogic server in debug mode, JSPX/JSFF files will hot deploy as soon as you save and reload the page.    You are also allowed to make changes to java methods as long as you don't change the structure of the class.  This means you can't add or remove methods, change method signatures or add or remove class properties or static members but you can change the code inside a method and instantly deploy the change while the server is running.   To do this hit CTRL+SHFT+F9 key combination.   This will compile and deploy the single java class that has been changed.   If it is successful you will see the message
"Redefined all recompiled classes that are loaded in the debuggee process.” 

 For a long time I had been using CTRL+F9 which performs a full build and hot deploy of the application.   Our application is very large and this would take over a minute to complete but  CTRL+SHFT+F9  will hot deploy a single file in about 1 second.  I don't know why this key combination is not front and center on the build menu (since CTRL+F9 is).  It should be included there because it is a huge time saver but the only way to learn about it is to browse the Tools Menu (Preferences/Shortcut Keys) to find it.   CTRL+F9  is now my most favorite keystroke.

Release 2 has much betters support for hot deploy.  I'm not using release 2 yet but here is blog that describes What works and what doesn't.


Tuesday, April 2, 2013

How to make each item in stragg list display on separate line



The stragg database function is useful for converting a subquery returning multiple rows into a single column containing a comma separated list of values.

I often use this function to display one of the columns in a row of data.  I recently had to format this so that each stragged item in the list displayed on it's own line.

This is the technique I used

The example subquery below will return a comma separated list of labels for a customer.  I'm only showing this one column selected for brevity but this would be one of many in the select clause.
The code in red was added to append a line feed character "chr(10)" to the beginning of each element in the list.  The substr(val,2) removes it from the 1st element so that it doesn’t begin with a line feed.


SELECT....
(SELECT  substr(stragg(chr(10) || label  ),2)
      FROM customer_label
      WHERE customer_label.account_id  = account.account_id
 ) labels,
 .... 

 FROM ....

 
Line feed characters are normally ignored in html but you can force them to be honored by applying a style of “white-space: pre-line”

add a style of pre to your output text within your table column


   <af:outputText value="#{row.label} styleClass="pre" />


The pre style is defined in SkinBasic.css (or whatever name is your custom skin)

/*** make line feed characters wrap.  For displaying line feed in table column ***/
.pre
{
  white-space: pre-line;
}

You could have also used inline style 
 <af:outputText value="#{row.label} inlineStyle="white-space: pre-line;" />



Thursday, March 7, 2013

How to Filter a table (QBE) using javascript

I recently had a requirement to double click some text on the page that would cause a table elsewhere on the page to populate one of the table column headers (Query by example) inputs and filter the table.   This can be done programmatically in a backing bean.  Here is a link to a forum thread for doing that and a sample can be downloaded from this page or directly with this link Programmatically Manipulating a Table's QBE Filter Fields  A different solution I came up with performs this action on the client side and was pretty simple to implement.   I was able to add the code for doing this to the jspx file while the server was running and test it without even having to restart the server.  I performed the following steps

  • Create a filter facet for the column you need to populate.  Add an inputText inside this facet and set it to be a clientComponent so that you can retrieve it on the clientSide by Id. (example)

                 <f:facet name="filter">
           
             <af:inputText value="#{vs.filterCriteria.MyColumnName}"
                                  simple="true"
                                  binding="#{requestScope.myColumnName}"
                                  id="ncode" clientComponent="true"/>
      </f:facet>
  • Add javascript method to a .js file loaded by your page that looks like this

    function filterByValue(){
      var flter= AdfPage.PAGE.findComponent(
    myColumnName); // retrieve filter input text
      flter.setValue("SomeValue")'  // populate the filter with your value
      // parent of the filter component is the table component
      flter.getParent().getPeer()._handleFilterCellAction(); // this submits the value (like hitting enter)
    }

     
  • The above code assumes there is a variable on the page named myColumnName contain the full component id of the inputText you are populating.  There are various ways to get this ID.   I used the technique described in my other blog posting here and set it using this script at the top of the page.  Note that ColumnName is an arbitrary name given to the component binding and is bound to requestScope so that it can be set into this javascript variable when the page loads.

    <trh:script text="var
    myColumnName= '#{ClientIdMap['requestScope.myColumnName']}';" /> 
  • Add a client listener to the component that you want to double click on

    <
    af:clientListener method="filterCollectorComments"  type="dblClick" /> 
That's is everything needed.  Double clicking the component will populate my filter table header and submit it.