Tuesday Aug 16, 2011

How-to hide or show components in printable pages

Not all web pages are suitable for printing, which means they contain components that either should not print, print different or should be replaces by other content. ADF Faces allows you to print pages using the af:showPrintableBehavior tag, which you add as a child to a command component.

http://download.oracle.com/docs/cd/E21764_01/apirefs.1111/e12419/tagdoc/af_showPrintablePageBehavior.html

The ADF Faces context object exposes an outputMode property that you can use to determine whether or not a page is rendered in printable mode. For example, the following EL is used on the Rendered properties of a column that should be hidden in a table for printable pages:
<af:column sortProperty="PhoneNumber" sortable="false" 
           headerText="…" id="c5"
           rendered="#{adfFacesContext.outputMode!= 'printable'}">
   <af:outputText value="…" id="ot11"/>
</af:column>

Similar, components can be added to the printable page. An af:switcher component could be used to change complete sections of a page for the printable output.

See also: http://download.oracle.com/docs/cd/E16162_01/web.1112/e16181/ad_output.htm#CHDIDBAB

ADF Faces web crawler support in Oracle JDeveloper 11.1.1.5 and 11.1.2

Web crawler support, also known as search engine optimization (SEO), has been added to ADF Faces in Oracle JDeveloper 11.1.1.5 (PS4) and Oracle JDeveloper 11g R2 (11.1.2).

"Search engine optimization (SEO) is the process of improving the visibility of a website or a web page in search engines via the "natural" or un-paid ("organic" or "algorithmic") search results."

- Wikipedia, http://en.wikipedia.org/wiki/Search_engine_optimization

The difference between ADF Faces pages queried by a user and a web crawler is that the agent is different in that browsers know how to render and display dynamic JavaScript, whereas a crawler cannot.

To index a page, crawlers need static links pointing to wherever site navigation goes to next. In addition, the ADF Faces window and controller token prevented pages from being indexed successfully. This has now been fixed for Oracle JDeveloper 11.1.1.5 and 11.1.2.

The documentation for this new feature is in the Oracle Fusion Middleware Web User Interface Developer's Guide for Oracle Application Development Framework for the two releases:

http://st-doc.us.oracle.com/review/rsb/html/B31973_09/ad_output.htm#CHDEIGJB (11.1.1.5)

http://download.oracle.com/docs/cd/E16162_01/web.1112/e16181/ad_output.htm#CHDEIGJB (11.1.2)

As documented, you can also use EL to "tune" pages for web indexing. A documentated sample shows how to enrich an ADF Faces page with a "goLink" to indicate navigation to another site.

<c:if test="#{requestContext.agent.type == 'webcrawler'}">
<af:goLink text="This Link is rendered only for web crawlers"
destination="http://www.newPage.com"/>
</c:if>

Note that there is nothing developers need to configure or do for the search engine optimization to work. More work on web crawler optimization is planned for ADFc in a future release of Oracle JDeveloper (no release dates and no further details available).

Friday Aug 12, 2011

Disabling the browser form auto-complete

As often, somebody's heaven is another one's hell. The browser auto-complete functionality is one example for this. In Oracle ADF Faces, there is no property that switches auto complete-off for input field components or the af:form component. Thanks to the ADF Faces client side architecture switching off this browser functionality is easy to achieve:

<af:form> 
  
  <af:clientListener  type="mouseOver"
                      method="suppressAutoComplete"/>
</af:form>

The mouse over event is issued one time when you enter a form. Given that you can only have a single form on a page, this means it fires one time for the page.

The JavaScript function referenced by the af:clientListener element is shown below

function suppressAutoComplete(evt){
 var domElement =
     AdfRichUIPeer.getDomContentElementForComponent(evt.getSource());
 domElement.setAttribute("autocomplete", "off" ); 
}

If you put this into a JS library that you reference from the af:resource tag then all you need to remember is add the af:clientListener tag to the af:form tag.

Update May-2012: Switching off browser suggest functionality is now a native capability of the inputText component in Oracle JDeveloper 11.1.2+ Read about the "autoComplete" property in http://docs.oracle.com/cd/E16162_01/apirefs.1112/e17491/tagdoc/af_inputText.html

Tuesday Aug 09, 2011

Disabling keyboard input on af:inputDate

Setting the ReadOnly property on an af:inputDate component to true does not only make the input field read-only but also hides the calendar icon.

If the use case is to force users to always select an input date from the popup calendar and to prevent keyboard input, as show in the image above, you can use a JavaScript based solution as shown below:

<af:resource>
  function disableEntry(evt){  
    evt.cancel(); 
  } 
 </af:resource>
<af:inputDate label="Label 1" id="id1" readOnly="false"
  contentStyle="background-color:lightgray;">
  <af:clientListener method="disableEntry" type="keyDown"/>
</af:inputDate>

The contentStyle attribute sets the af:inputDate field background color to light gray to indicate a read-only field.

Note: If the read-only setting is for all instances af:inputDate then, instead if using the contentStyle attribute, you use skinning af|inputDate::content{background-color:lightgray;}

Tuesday Aug 02, 2011

Suggested skin editor workflow

Following the work flow outlined below helps you to create a custom skin for your AD Faces application using the integrated or stand alone skin editor.

Integrated Skin Editor

The integrated skin editor is good to use for projects that are migrated or newly created in Oracle JDeveloper 11g R2.

1. Create a skin project. Skins are reusable components and as such should be created in their own project or workspace.

2. Create a new skin by extending an existing skin. Oracle ADF Faces provides simplified default skins, like fusionFx-simple-v2.desktop, that are specifically designed to be extended by custom skins. Note that Fx-simple-v2 is not available for releases before Oracle JDeveloper 11g R2. If you are on an 11.1.1.x version of Oracle JDeveloper, use the stand-alone editor. The stand-alone editor helps with which default skins are available for the target version you build the skin for.

3. Analyze the application for the components to skin. Identify the components in a page that you want to skin and map them to skin selectors using the ADF Faces skin editor.

4. Identify global alias selectors to skin first. Alias selectors are the 20% of work that color 80% of the components in an application.

5. Define custom :alias definitions: Custom :alias definitions simplify maintenance of style definitions used on multiple components. Custom :alias definitions are applied using the –tr-rule-ref selector,

6. Generate images and icons. Use the ADF Faces skin editor to generate custom colored versions of ADF Faces component images and icons.

7. Edit the skin CSS file using the skin editor. Use the skin editor to discover skin selectors for the components and behavior you want to skin and apply the changes using the Properties Inspector.

8. Deploy the skin in an ADF library. Skins can and should be reused. For this, create an ADF library deployment profile from the skin project and deploy the skin in a JAR file.

9. Frequently test your custom skin in a browser. Reference the skin JAR file from the ViewController project of the target application. Set the custom skin family name in the skin-family element of the target application trinidad-config.xml file.

10. Deploy the skin as a shared library to WebLogic server. Optionally, if a custom skin is shared across applications, deploy the skin ADF library JAR file as a shared library to Oracle WebLogic server and edit the applications' weblogic-application.xml file to reference it.

Stand-alone Skin Editor

The stand-alone skin editor allows you to build custom skins for projects build with Oracle JDeveloper 11.1.2, 11.1.1.5 and 11.1.1.4. If you build sins for JDeveloper versions prior to 11.1.1.4, just make sure you either don't extend an existing skin or extend one that exists in the target JDeveloper version. Note that the FusionFx simple skin is not available for all version of JDeveloper.

You could extend the "fusion" skin instead, which however is more difficult to skin as it isn't reduced to using global alias selectors as the simple skins do.

The work flow to follow for the stand alone editor is comparable to using the integrated editor

1. Create a skin project. Skins are reusable components and as such should be created in their own project or workspace. Never open a JDeveloper 11.1.1.x project directly in the stand alone skin editor as it is JDeveloper 11.1.2 based and thus will migrate the project to JDeveloper 11.1.2 and JSF 2.0.

2. Create a new skin by extending an existing skin. Oracle ADF Faces provides simplified default skins, like fusionFx-simple-v2.desktop, that are specifically designed to be extended by custom skins. When creating a new skin project, select the target version of Oracle JDeveloper you build the skin for, which then automatically updates the list of available default skins for this platform.

3. Analyze the application for the components to skin. Identify the components in a page that you want to skin and map them to skin selectors using the ADF Faces skin editor.

4. Identify global alias selectors to skin first. Alias selectors are the 20% of work that color 80% of the components in an application.

5. Define custom :alias definitions: Custom :alias definitions simplify maintenance of style definitions used on multiple components. Custom :alias definitions are applied using the –tr-rule-ref selector,

6. Generate images and icons. Use the ADF Faces skin editor to generate custom colored versions of ADF Faces component images and icons.

7. Edit the skin CSS file using the skin editor. Use the skin editor to discover skin selectors for the components and behavior you want to skin and apply the changes using the Properties Inspector.

8. Deploy the skin in an ADF library. Skins can and should be reused. For this, create an ADF library deployment profile from the skin project and deploy the skin in a JAR file.

9. Frequently test your custom skin in a browser. Reference the skin JAR file from the ViewController project of the target application. Set the custom skin family name in the skin-family element of the target application trinidad-config.xml file.

10. Deploy the skin as a shared library to WebLogic server. Optionally, if a custom skin is shared across applications, deploy the skin ADF library JAR file as a shared library to Oracle WebLogic server and edit the applications' weblogic-application.xml file to reference it.

You can take this work flow as a starting point to refine and build your own. I am sure there is a lot more to add, like skin debugging, before this laundry list can become an idiots-guide. Anyway, I am interested in hearing back from you of what you think would be a valuable addition to this work flow. I opened a thread on the JDeveloper forum on OTN for this:.

http://forums.oracle.com/forums/thread.jspa?threadID=2262307&tstart=0

At the end of the month, I'll then put it all together in the monthly OTN harvest for August published on the ADF Code Corner Website:

http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html 

You can download the stand-alone ADF Faces Skin Editor from here: http://www.oracle.com/technetwork/developer-tools/adf/downloads/index.html

Friday Jul 08, 2011

How-to access UI component that queued a custom client event

In ADF Faces, to invoke a server side method in a managed bean, you use the af:serverListener tag. The af:serverListener tag is added as a child to the component that owns the event and called from JavaScript in a call to AdfCustomEvent.queue( … )

In this example, the af:serverListener is added to a table to notify a manage bean method about a double-click action.

<af:table ...>
 <af:column> ... </af:column>
 ...
 <af:clientListener method="handleTableDoubleClick"
                   type="dblClick"/>
<af:serverListener type="TableDoubleClickEvent"                          
                   method="#{myBean.handleTableDoubleClick}"/>
</af:table> 

The JavaScript function that is called by the af:clientListener is shown next.

function handleTableDoubleClick(evt){   
  var table = evt.getSource();
  AdfCustomEvent.queue(table, "TableDoubleClickEvent",{}, true);         
  evt.cancel();
}

The first argument in the call to AdfCustomEvent.queue represents the event owner, the table component. This information is passed to the managed bean method, which has the following signature.

public void handleTableDoubleClick(ClientEvent ce){
  RichTable richTable = (RichTable)ce.getComponent(); 
  //... work with rich table component
}

As you can see, there is no need to look up the event owning component by searching the JSF UIViewRoot with or without help of JSFUtils.

Thursday Jul 07, 2011

favicon and browser bookmark icons in JDeveloper 11.1.2

The favicon is the little icon that displays in the Browser URL address field when a requested page loads. In Oracle JDeveloper 11.1.1.x releases, the favicon needed to be added to the page source. In JDeveloper 11.1.2 a new attribute, smallIconSource has been added to the af:document tag to serve the favicon easily.

See: http://download.oracle.com/docs/cd/E16162_01/apirefs.1112/e17491/tagdoc/af_document.html

smallIconSource

Specifies a small icon that the browser may insert into the address bar (commonly known as a "favicon"). If this attribute is not specified, the browser may default to using a file named "favicon.ico" located at the root of your server. (This default behavior is not something provided by this framework and may vary between browsers.) This attribute supports a space-delimited list of files (each file may be wrapped in quotes or apostrophes if the file path contains a space). If the file path specifies a single leading slash, this means that the file is located inside of the web application's root folder (so "/small-icon.png" would resolve to something like "http://www.oracle.com/adf-faces/small-icon.png"). If the file path specifies 2 leading slashes, this means that the file is located inside of the server's root folder (so "//small-icon.png" would resolve to something like "http://www.oracle.com/small-icon.png"). Browsers typically expect these files to be 16 pixels by 16 pixels. Typically, the first listed file will be the one used. Otherwise, if a browser only supports certain kinds of files, the first file in the list that uses a supported file extension will be the one that is used for that browser.

Another new attribute is the largeIconSource that applies an image to bookmark entries in borwsers.

largeIconSource

Specifies a large icon that the browser may use when bookmarking this page to your device's home screen. If this attribute is not specified, the browser may default to using a file named "apple-touch-icon.png" located at the root of your server. (This default behavior is not something provided by this framework and may vary between browsers.) This attribute supports a space-delimited list of files (each file may be wrapped in quotes or apostrophes if the file path contains a space). If the file path specifies a single leading slash, this means that the file is located inside of the web application's root folder (so "/large-icon.png" would resolve to something like "http://www.oracle.com/adf-faces/large-icon.png"). If the file path specifies 2 leading slashes, this means that the file is located inside of the server's root folder (so "//large-icon.png" would resolve to something like "http://www.oracle.com/large-icon.png"). Browsers typically expect these files to be 57 pixels by 57 pixels but could be larger, e.g. 72 pixels by 72 pixels or 129 pixels by 129 pixels. Typically, the first listed file will be the one used. Otherwise, if a browser only supports certain kinds of files, the first file in the list that uses a supported file extension will be the one that is used for that browser.

<af:document title="My Page"
  smallIconSource="/favicon.png /favicon.ico"
  largeIconSource="/touchicon.png">
  <af:form> ... </af:form>
</af:document>

New client behavior tag - af:checkUncommittedDataBehavior

In Oracle JDeveloper 11.1.2, a new client behavior tag af:checkUncommittedDataBehavior is provided to check for uncommitted data when navigating away from a page using a command button that has its immediate property set to true. The tag can be applied as a child of any command component, like

  • af:commandButton
  • af:commandLink
  • af:commandMenuItem
  • af:commandToolbarButton

http://download.oracle.com/docs/cd/E16162_01/apirefs.1112/e17491/tagdoc/af_checkUncommittedDataBehavior.html

For the client behavior to work, you must set the document tag's uncommittedDataWarning attribute to on.

Just as a reminder: Client behavior tags in ADF Faces execute on the client side. They are there to save you from writing JavaScript, thus abstracting you from the complexity of the underlying client side APIs.

Wednesday Jun 22, 2011

JDeveloper 11.1.2 : Command Link in Table Column Work Around

 Just figured that in Oracle JDeveloper 11.1.2, clicking on a command link in a table does not mark the table row as selected as it is the behavior in previous releases of Oracle JDeveloper. For the time being, the following work around can be used to achieve the "old" behavior:

To mark the table row as selected, you need to build and queue the table selection event in the code executed by the command link action listener. To queue a selection event, you need to know about the rowKey of the row that the command link that you clicked on is located in. To get to this information, you add an f:attribute tag to the command link as shown below

<af:column sortProperty="#{bindings.DepartmentsView1.hints.DepartmentId.name}" sortable="false"
   headerText="#{bindings.DepartmentsView1.hints.DepartmentId.label}" id="c1">
  <af:commandLink text="#{row.DepartmentId}" id="cl1" partialSubmit="true"
      actionListener="#{BrowseBean.onCommandItemSelected}">
    <f:attribute name="rowKey" value="#{row.rowKey}"/>
  </af:commandLink>
  ... 
</af:column>

The f:attribute tag references #{row.rowKey} wich in ADF translates to JUCtrlHierNodeBinding.getRowKey(). This information can be used in the command link action listener to compose the RowKeySet you need to queue the selected row. For simplicitly reasons, I created a table "binding" reference to the managed bean that executes the command link action. The managed bean code that is referenced from the af:commandLink actionListener property is shown next:

public void onCommandItemSelected(ActionEvent actionEvent) {

  //Do here what the command link is supposed to do
  // …  

   //In the following, set the current row  to the row that the command
   //link the user pressed is in

  //get access to the clicked command link 
  RichCommandLink comp = (RichCommandLink)actionEvent.getComponent();
  //read the added f:attribute value
  Key rowKey = (Key) comp.getAttributes().get("rowKey");
 
  //get the current selected RowKeySet from the table
  RowKeySet oldSelection = table.getSelectedRowKeys();
  //build an empty RowKeySet for the new selection
  RowKeySetImpl newSelection = new RowKeySetImpl();
  
  //RowKeySets contain List objects with key objects in them
  ArrayList list = new ArrayList();
  list.add(rowKey);
  newSelection.add(list);
  
  //create the selectionEvent and queue it
  SelectionEvent selectionEvent = new SelectionEvent(oldSelection, newSelection, table);
  selectionEvent.queue();   

  //refresh the table
  AdfFacesContext.getCurrentInstance().addPartialTarget(table);
}

Update 07/2011

While the solution above works nice for links that don't navigate off the page, it doesn't work well in a master-detail scenario where the detail collection is displayed on a separate page. To cover this use case I provided an ADF sample workspace that uses EJB and TopLink as a model. The sample shows two use cases that both show on the second page:

1. The employee data displayed on the ViewEmployees.jsf page is read from a dependent collection of the departmentsFindAll collection

2. The employee data displayed on the ViewEmployees.jsf page is read from the return of a finder method getEmployeesFindbydepartmentId.

 The changed code is shown below:

public void onDepartmentsRowSelection(ActionEvent actionEvent) {
  //Set the current row  to the row that the command
  //link the user pressed is in get access to the clicked
  //command link

  //USE CASE 1 ---- DEPENDENT COLLECTION  (departmentsFindAll

  //setting the row currency for the departments will then
  //implicitly query dependent childs in table 1 on pae 2
  RichCommandLink comp = (RichCommandLink)actionEvent.getComponent();
  //read the added f:attribute value
  Key rowKey = (Key) comp.getAttributes().get("rowKey");
  //table sis parent/parent of link
  RichTable table = (RichTable) comp.getParent().getParent();
  CollectionModel model = (CollectionModel) table.getValue();
  JUCtrlHierBinding treeBinding = (JUCtrlHierBinding)model.getWrappedData();
  DCIteratorBinding iterator = treeBinding.getDCIteratorBinding();
  iterator.setCurrentRowWithKey(rowKey.toStringFormat(true));  
 
  //USE CASE 2 ---- INDEPENDENT COLLECTION 

  //prepare attribute for page navigation. This attribute is looked up by
  //the getEmployeesFindByDepartmentId finder method on page 2
  ADFContext adfCtx = ADFContext.getCurrent();
  Map pageFlowScope = adfCtx.getPageFlowScope();
  pageFlowScope.put("rowKey", rowKey.getAttribute(0));    
}

The sample handles both cases in the managed bean that handles the action event on the command link in the table. You can download the workspace from here:

http://blogs.oracle.com/jdevotnharvest/resource/AdfEjbSample.zip

Open the sample application in JDeveloper 11.1.2.0 and change the database connection to a database of yours that has the HR schema installed and enabled.

Note: Once the mentioned selection problem is fixed, this sample is no longer required other than to learn how to access a command link and its parent table from a managed bean. Use case 1 then will work out-of-the-box using pure declarative development gestures.


        
    

Thursday Jun 09, 2011

How-to notify the server when user tabs out of input field

Though the use case covered in this section is more of an individual problem than of generic interest, the code involved to implement the solution may be useful. First the use case: For an input text component, a notification should be sent to the server when the user steps out of the field using mouse or the keyboard navigation. The notification should be sent no matter if users changed the field content (in which case a value change listener would have done) or not (in which case a value change listener is not enough). The solution to this problem is to use an af:clientListener tag on the input tag component to invoke a JavaScript function when the user leaves the field (The component event for this is "blur").

Using an af:serverListener tag on the input text component then allows to notify the server from the JavaScript function.

<f:view>
  <af:document id="d1"> 
    <af:resource type="javascript">
       function onBlurTxtField(evt){
          var source = evt.getSource(); 
          var custEvent = new AdfCustomEvent(source,"onBlurNotifyServer",
                       {submittedValue : source.getSubmittedValue(),
                        localValue : source.getValue()}
                         ,true);
          custEvent.queue(); 
       }
   </af:resource>
   <af:form id="f1">
     <af:inputText label="Label 1" id="it1">
        <af:clientListener   method="onBlurTxtField" type="blur"/>
        <af:serverListener   type="onBlurNotifyServer"
                             method="#{TxtHelper.onBlurNotify}"/>
     </af:inputText>
     <af:inputText label="Label 2" id="it2"/>
   </af:form>
  </af:document>  
</f:view>

The page code above sends a custom event to the server whenever a user leaves the input text field. The payload sent to the server contains the submitted and the local component value. Note that in the above sample --- as we will see next --- the payload is not really required because the same information can be accessed from the component instance in the referenced managed bean method.

<af:serverListener type="onBlurNotifyServer"
                   method="#{TxtHelper.onBlurNotify}"/>

The managed bean method receives a single argument of type ClienEvent:

public void onBlurNotify(ClientEvent clientEvent) {
    // get a hold of the input text component
    RichInputText inputTxt =  RichInputText) clientEvent.getComponent(); 
    //do some work on it here (e.g. manipulating its readOnly state)
    //…
    //Get access to the payload
   Map  parameters = clientEvent.getParameters();
   System.out.println("SubmittedValue = "+parameters.get("submittedValue"));
   System.out.println("LocalValue =  +parameters.get("localValue"));
}

As mentioned, the use case may not be of generic interest. However, the way you work with the client and server listener for sure made sense to publish as an example.

Wednesday May 25, 2011

Invoking af:exportCollectionActionListener from Java

The af:exportCollectionListener tag is a client behavior tag in ADF Faces. Client behavior tags implement functionality that requires JavaScript on the client side if coded manually by application developer. In fact, client behavior tags wrap the JavaScript that is required for a solution and expose a JSF tag for declarative use instead. The af:exportCollectionListener exports the visible content of a collection, like exposed in an ADF Faces table, to Excel. The tag is dragged on top of a command item, like a toolbar button or a command button, and then configured with the table id for which rows should be exported, the name of the file to produce, whether you want to export all rows or just those that are selected, and an optional title string. For more information, see the tag documentation:

http://download.oracle.com/docs/cd/E17904_01/apirefs.1111/e12419/tagdoc/af_exportCollectionActionListener.html

When the command item that has the af:exportCollectionListener tag added is invoked by a user, the tag is executed as well and produces the desired output. However, applications usually are a lot more dynamic than to wait for a user to press a button. Instead developers may want to invoke the client behavior programmatically, which in case of a client behavior you can do using JavaScript

var button = AdfPage.PAGE.findComponentByAbsoluteId('pc1:ctb1');
if (button != null)
{
  AdfActionEvent.queue(button);
}  

The JavaScript code above looks an ADF Faces component up in a search from the page root. The component is identified by its absolute component Id ('pc1:ctb1' in the example as the button is in a toolbar facet of a panel collection, which is a naming container). If the component is found, the client event – AdfActionEvent – is queued for the button, which virtually presses it.

However, what if you don't want JavaScript in your application code? In this case, you can use Java to invoke JavaScript from a managed bean. The following code sample provides a method that is called from Java logic in your managed bean to composes the JavaScript String and to invoke it on the client:

import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;  
public void magicallyPressToolbarCommand(String id) {
  FacesContext fctx = FacesContext.getCurrentInstance();
  UIViewRoot uiViewRoot = fctx.getViewRoot();
  UIComponent comp = uiViewRoot.findComponent(id);
  //check if the component is a command component. For the 
  //exportCollectionListener this is important as we need to 
  //queue a client side action event
  if (comp != null && (comp instanceof UIXCommand)) {
    String clientId = comp.getClientId(fctx);
    StringBuffer scriptBuffer = new StringBuffer();
    scriptBuffer.append("var button = 
                       AdfPage.PAGE.findComponentByAbsoluteId('");
    scriptBuffer.append(clientId + "');");
    scriptBuffer.append("if (button != null){");
    scriptBuffer.append("AdfActionEvent.queue(button);}");
    writeJavaScriptToClient(scriptBuffer.toString());
  } 
  else {
    //ID probably not found. Log the issue
     System.out.println("Component with ID " + id + " not Found !!!");
    //TODO - use proper ADFLogger print message
  }
}
//universal helper method for invoking scripts on the client
private void writeJavaScriptToClient(String script) {
  FacesContext fctx = FacesContext.getCurrentInstance();
  //Trinidad classes
  ExtendedRenderKitService erks = null;
  erks = Service.getRenderKitService(fctx,
  ExtendedRenderKitService.class);
  erks.addScript(fctx, script);

}

What you need to pay extra attention to is the ID of the component ( a toolbar component in my example). If a component is within a naming container like PageTemplate, Table, PanelCollection, Region, etc. then the ID(s) of the surrounding naming containers must be added as a prefix to the component ID. The form is namingContainerId:componentId.

Disadvantage of using JavaScript in Java: The script is harder to debug on the client.

One more challenge!

Okay, now that I showed how to invoke a command item on a client using JavaScript from Java, what if you don't want to have a button showing in the UI? In this case, it should be the application logic only that invokes the af:exportCollectionAtionListener. In this case you still add a command item to the page but set its Visible property to false. This way the command item is hidden in the user interface, but the functionality is still available for the application to use.

Note: Don't however try the same setting the "Rendered" property to false. If a component is not rendered then it cannot be found and invoked on the client.

Wednesday Apr 20, 2011

Using af:resource tag in page fragments

[Read More]

Monday Apr 11, 2011

About JSF fragments, ADF regions, declarative components …

[Read More]

Wednesday Mar 09, 2011

How-to filter table filter input to only allow numeric input

[Read More]

Monday Mar 07, 2011

How to display a dependent list box disabled if no child data exist

[Read More]
About

The Oracle JDeveloper forum ranks in the Top 5 of the most active forums on the Oracle Technology Network (OTN).



The OTN Harvest blog is a summary of selected topics posted on the OTN Oracle JDeveloper forum.



It is an effort to turn knowledge exchange into an interesting read for developers who enjoy little nuggets of wisdom





Frank Nimphius

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today