Sunday 6 January 2013

Perform a Default Button Action for a Page and Particular Region

If you are in any page and think that if you pressed Enter Key then need to perform some actions by default is nothing Default Button Action. In a Web based application default button action is required. If you want to achieve then we need to use the following tags.

Before using the below tags need to consider the below points for giving an Id to the attribute.
  • Identifiers are relative to the component, and must account for Naming Containers.
  • Use a single colon(:) to start the search from the root
  • Use a multiple colons to move up through the Naming Containers( :: for One Level Up, ::: for two Level Up and etc.,)

<af:form>
The UnifiedForm component creates an HTML <form> element and can able to use only one af:form component per page. There is property called 'defaultCommand', is going to use for set the default action of the form/page.

The property of 'defaultCommand' value is an id attribute of the command button inside the form whose action should be invoked by default when the enter key is pressed with focus inside the form. If defaultCommand is not specified, no action is invoked when the enter key is pressed with focus inside the form.


<af:subform>
The Subform represents an independently submittable region of a page. The contents of a subform will only be validated (or otherwise processed) if a component inside of it for submitting the page or if the default attribute is set to true while no other subform is responsible for submitting the page.
  • This allows for comparatively fine-grained control of which components will be validated and pushed into the model without the compromises of using entirely separate form elements.
  • Should not have a component with immediate set to true in a subform. A Component with immediate set to true will still be validated even though the containing subform is not responsible for submitting the page.

The property of 'default', whether the subform should assume it has been submitted. When set to "true", "submitted" will be considered true if no other subform has been submitted.

The property of 'defaultCommand' value is a client id of the command component inside the subform whose action should be invoked by default, when the enter key is pressed with focus inside the subform. This attribute overrides the defaultCommand set on form.


ADF strongly recommend the use of a single <af:form> per page, and using <af:subform> where you might otherwise be tempted to use multiple forms. Multiple forms require multiple copies of page state, and user edits in forms that aren't submitted are always lost. When a page using subforms is submitted, page state is only written once, and all user edits are preserved.

For more details check with sample.

You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11g R2 Update3]

How to run this sample?
Run using the PageDefaultButtonAction.jspx and check the behaviors <af:form> with Default Command Actions by pressing Enter Key & RegionDefaultButtonAction.jspx and check the behaviors <af:subform> with Default Command Actions by pressing Enter Key.


1 comment: