Pages

Monday, November 24, 2014

Invoke Bindings from PageTemplate PageDef

Invoke Bindings from PageTemplate PageDef

There are scenarios when certain method binding in pageTemplate's pageDef needs to be invoked from some button Action in page. Here are the details :

1. For page based on the pageTemplate, there will be reference of pageTemplate's PageDef created in page's pageDef.



2.  Now in order to access bindings in pageTemplate's pageDef, refer below code. Enjoy!!!

Thursday, November 20, 2014

Show exceptions caught in Managed Beans

There are couple of scenarios when some exception is caught while executing some logic in managed bean. The post is about how to show those exceptions to user and when it is required to do it explicitly.

For most of the scenarios, ADFm Error Handlers shows the message. But in case when some exception occurs in managedBean, it can be caught and reported to ADFm Error Handler using below code.

BindingContext bctx = BindingContext.getCurrent();
   ((DCBindingContainer)bctx.getCurrentBindingsEntry()).reportException(ex);

Note : Using the ADF model error handling for displaying exceptions thrown in managed beans require the current ADF Faces page to have an associated PageDef file (which is the case if the page or view contains ADF bound components).

Sample App is uploaded here. Following scenarios are covered  :

Scenario Description Button Text in Sample App Requires Explicit Handling to show messaage to User
1 Drag and Drop AM Method on Page as command Button throwJboExceptionFromAM No
2 Call AM method in Bean method through bindings Call throwJboExceptionFromAM in Bean through Bindings No. By default, all exception are handled by ADFm Error Handler when calling AMMethod through bindings. When you check for exception in operationBinding and report it expliclity .. It is basically duplicating the message
3 throw an exception in ActionListener ThrowingExceptionInActionListener Yes. See the button in section Handled and it's actionListener. How the exception is reported .


Enjoy !!!

Friday, November 14, 2014

Setting Button Action from ActionListener

Control the button Action based on the logic inside ActionListener 

 This post talks about how to control the button Action based on the logic inside ActionListener. Lets say there is a commandButton "Go to View2" on pageFragment "View1" . On Click of this button conditionally a navigation is required. Here goes the code :

That's all ..enjoy.


Tuesday, November 11, 2014

SelectBooleanCheckbox with [Y, N] values using a custom converter

How to show selectBooleanCheckbox with [Y,N} values using a custom converter.

So first we need a converter which converts [Y,N] to [true, false] and viceversa. Here goes the converter code :-


Converter needs to be declared in faces-config.xml ..

Next goes the code snippet showing usage of our converter in selectBooleanCheckbox.


Enjoy!!