A simple demo application that uses Entity Object based on the Stored Procedure is attached here.
More details can be found in Developer's Guide, section 37.5 Basing an Entity Object on a PL/SQL Package
PS: Unzip the attachment and run the script(StoredProcedureExample/script) to set up the required DB objects for running this demo
Oracle ADF is a powerful application framework for building next generation enterprise applications. This blog discusses some interesting use case scenarios and solutions using ADF and the underlying Java EE technologies.
The views expressed on this blog are my own and do not necessarily reflect the views of my employer.
Sunday, October 18, 2009
Friday, October 16, 2009
Reset the content of a web page
Resetting the page contents or undoing the changes made by a user is a very common use case scenario in Rich Internet Applications. The 'reset action' should skip all validations defined on the current page and page contents needs to restored from the underlying data layer. Some of the web frameworks support this feature out of the box. Let me try explaining possible ways to reset a page when developing applications using ADFFaces.
1. <af:resetButton>
As the name suggests, af:resetButton resets the contents of a form. Please note that developer doesn't have much control here as he/she might not be able to bind any action method with this built in reset button.
This tag is usually bound to an action source like command button to reset all submitted values whenever an action is triggered. Obviously this gives more control to the developer as the action sources like command button can be optionally bound to an action method through the Expression Language(EL). Please note that, you may need to keep immediate="true" for the command button ( for the action source ) to skip the validations while implementing the reset/cancel behavior.
Each component has local cache value. When you submit a form, submitted value gets assigned to this localValue at the end of 'PROCESS VALIDATIONS' pahse, and thereafter submitted value is set as null. During the RENDER RESPONSE, first consult the local value property of this component. If non-null return it. If null, see if we have a ValueExpression for the value property. UIInput::resetValue() reset the submitted value that would force the rendering logic to take the value from the model/binding layer.
3. Custom Reset Implementation
So far so good, but in some scenarios developers may need to dirty their hands a bit to get the job done - where the declarative 'reset' support is missing. I noticed a rare use case scenario recently, that calls for custom reset implementation. There master-detail data is displayed in tabular form and user is allowed to edit one master record (and it's children as well) at a time, then save that record and proceed to next. In case user decided to navigate to next record without saving current record, then current changes needs to be cancelled. Though use case is bit odd one, adding this feature is pretty simple. All we need to is override the default selectionListener and from this custom method, parse the component tree and call reset on each element.
Code Snippet:
On a related note, I would suggest you to look at the source of org.apache.myfaces.trinidadinternal.taglib.listener.ResetActionListener, that may help you to understand the 'reset' concept much better. (Even the below given sample application just tries to reuse the same reset logic from ResetActionListener class).
You can download the sample workspace from here.
1. <af:resetButton>
As the name suggests, af:resetButton resets the contents of a form. Please note that developer doesn't have much control here as he/she might not be able to bind any action method with this built in reset button.
<af:resetButton text="ResetButton" id="rb1"/>
2. <af:resetActionListener>This tag is usually bound to an action source like command button to reset all submitted values whenever an action is triggered. Obviously this gives more control to the developer as the action sources like command button can be optionally bound to an action method through the Expression Language(EL). Please note that, you may need to keep immediate="true" for the command button ( for the action source ) to skip the validations while implementing the reset/cancel behavior.
<af:commandButton text="Cancel with resetAction" id="cb2" immediate="true"
partialSubmit="true"
actionListener="#{SomeBean.cancelBusinessAction}">
<af:resetActionListener/>
</af:commandButton>
Why do we need to reset submitted values? Each component has local cache value. When you submit a form, submitted value gets assigned to this localValue at the end of 'PROCESS VALIDATIONS' pahse, and thereafter submitted value is set as null. During the RENDER RESPONSE, first consult the local value property of this component. If non-null return it. If null, see if we have a ValueExpression for the value property. UIInput::resetValue() reset the submitted value that would force the rendering logic to take the value from the model/binding layer.
3. Custom Reset Implementation
So far so good, but in some scenarios developers may need to dirty their hands a bit to get the job done - where the declarative 'reset' support is missing. I noticed a rare use case scenario recently, that calls for custom reset implementation. There master-detail data is displayed in tabular form and user is allowed to edit one master record (and it's children as well) at a time, then save that record and proceed to next. In case user decided to navigate to next record without saving current record, then current changes needs to be cancelled. Though use case is bit odd one, adding this feature is pretty simple. All we need to is override the default selectionListener and from this custom method, parse the component tree and call reset on each element.
Code Snippet:
public void customSelectionHandler(SelectionEvent selectionEvent) {
UIComponent source = (UIComponent)selectionEvent.getSource();
UIComponent uiComp = _getRootToReset(source);
_resetChildren(uiComp);
EL.invokeMethod(
"#{bindings.DepartmentsView11.collectionModel.makeCurrent}",
SelectionEvent.class, selectionEvent);
}
On a related note, I would suggest you to look at the source of org.apache.myfaces.trinidadinternal.taglib.listener.ResetActionListener, that may help you to understand the 'reset' concept much better. (Even the below given sample application just tries to reuse the same reset logic from ResetActionListener class).
You can download the sample workspace from here.
Subscribe to:
Posts (Atom)