http://www.developer.com/tech/article.php/3741411/Implementing-AJAX-Components-in-the-JWL-Framework.htm
In 2005, IBM© introduced JWL (JavaScript-based Widget Library); it enhances JSP and HTML pages with rich set of inputs, output, and navigation components. If you are not familiar with JWL and would like to learn more about it, you can reference the following articles under the IBM Developer Works web site to give you an idea of what JWL can offer: With the release of RAD 6.0 (Rational Application Developer), IBM has introduced a much improved support systemfor JWL AJAX components. In this article, you will find out about these components and go through three how-to exercises. You will also find sample source code that you can import into your workspace. An AJAX tag must be defined as a child tag of any of the JWL panel tags. The AJAX tag defines an alternate content for the panel. An AJAX tag makes a server request when the panel containing the AJAX tag is invoked. The server processes the request and returns control to the panel. There are three AJAX components under JWL library. These are discussed in detail in the following sections. The <hx:ajaxRefreshRequest> tag allows for the content of the same JSF page to be asynchronously replaced within the parent tag. The content is retrieved by using the HTTP GET request. This tag is used when you do not need to pass a lot of information to the server or you are interested in only a limited number of parameters as opposed to the whole form. The following steps describe how this tag is used: Figure 1: Create a new AjaxRefreshRequestExample.jsp Figure 2: View of the "Palette" Pane Listing 1: Input Component Source Code Figure 3: Properties of the OutputText Component Figure 4: AJAX Properties Figure 5: AjaxRefreshRequest Properties Listing 2: Submit Button "Behavior" Source Code Figure 6: Running the Example on Websphere 6.1 Server Figure 7: AjaxRefreshRequest Example Output Listing 3 is the full source code of what you have just gone through. You can find full source code as an attachment at the end of this article. Listing 3: AjaxRefreshRequest Example—Full Source Code <hx:ajaxRefreshSubmit> tag allows for the content of the same JSF page to be asynchronously replaced within the parent tag. The content is retrieved using HTTP POST request. This tag is used when you want to submit the whole form to the server. The following steps describe how you can implement this tag: Figure 8: Create a New JSF Page Figure 9: The "Palette" Pane Listing 4: Three Input Text Fields Code Figure 10: AJAX Properties Listing 5: Submit Button "Behavior" Code Figure 11: Create New Java Class—ThreeStringsConcatenatorBean.java Listing 6: Implementation Of getConcatenateThreeFields() Method Figure 12: Create a New Faces Managed Bean Figure 13: Register a New Faces Managed Bean Figure 14: Map Bean Fields to Input Field on the Page Figure 15: Running the Example on the Server Figure 16: AjaxSubmitRequest Example Output Listing 7 is the full source code of what you have just gone through. You can find full source code as an attachment at the end of this article. Listing 7: AjaxSubmitRequest Full Source Code <hx:ajaxExternalRequest> defines how content from a different page replaces the content of the parent tag. Content is retrieved using HTTP GET method. This tag is useful when you want to place one JSP into the content of another one. The following steps describe how this tag is used: Figure 17: Creating a New AjaxExternalRequestExample.jsp Page Figure 18: View of the "Palette" Pane Figure 19: View of AJAX Properties Figure 20: AjaxExternalRequest Properties Figure 21: AjaxExternalRequest Example Output Listing 8 is the full source code of what you have just gone through. You can find full source code as an attachment at the end of this article. Listing 8: AjaxExternalRequest Full Source Code Aleksey Shevchenko has been working with object-oriented languages for eight years. For the past four years, he has served as a technical lead and a project manager. Aleksey has been implementing Enterprise IT solutions for Wall Street and the manufacturing and publishing industries.
Implementing AJAX Components in the JWL Framework
April 17, 2008
Introduction
Definitions
Get Content <hx:ajaxRefreshRequest>
Note: All exercises are done using RAD 6.1.

Click here for a larger image.

<f:view>
<body>
<hx:scriptCollector id="scriptCollector1">
<h:form id="form1" styleClass="form">
<h:inputText id="text"
styleClass="inputText">
</h:inputText>
</h:form>
</hx:scriptCollector>
</body>
</f:view>

Click here for a larger image.

Click here for a larger image.

Click here for a larger image.
<hx:behavior event="onclick"
behaviorAction="get"
targetAction="group1" />

Click here for a larger image.

<f:view>
<body>
<hx:scriptCollector id="scriptCollector1">
<h:form id="form1" styleClass="form">
<h:inputText id="text1"
styleClass="inputText">
</h:inputText>
<hx:commandExButton type="submit"
value="Submit"
id="button1"
styleClass="commandExButton">
<hx:behavior event="onclick"
behaviorAction="get"
targetAction="group1">
</hx:behavior>
</hx:commandExButton>
<h:panelGroup id="group1" styleClass="panelGroup">
<h:outputText id="text2" styleClass="outputText"
value="#{param.text1}">
</h:outputText>
</h:panelGroup>
hx:ajaxRefreshRequest id="ajaxRefreshRequest1"
target="group1" params="text1">
</hx:ajaxRefreshRequest>
</h:form>
</hx:scriptCollector>
</body>
</f:view>
Update Content <hx:ajaxRefreshSubmit>

Click here for a larger image.

<hx:scriptCollector id="scriptCollector1">
<h:form id="form1" styleClass="form">
<h:inputText id="text1"
styleClass="inputText">
</h:inputText>
<h:inputText id="text2"
styleClass="inputText">
</h:inputText>
<h:inputText id="text3"
styleClass="inputText">
</h:inputText>
</h:form>
</hx:scriptCollector>

Click here for a larger image.
<hx:behavior event="onclick"
behaviorAction="get"
targetAction="group1" />

Click here for a larger image.
public String getConcatenateThreeFields() {
return text1 + text2 + text3;
}


Click here for a larger image.

Click here for a larger image.

Click here for a larger image.

Click here for a larger image.
<f:view>
<body>
<hx:scriptCollector id="scriptCollector1">
<h:form id="form1" styleClass="form">
<h:inputText id="text1"
styleClass="inputText"
value="#{concatenatorBean.text1}">
</h:inputText>
<h:inputText id="text2"
styleClass="inputText"
value="#{concatenatorBean.text2}">
</h:inputText>
<h:inputText id="text3"
styleClass="inputText"
value="#{concatenatorBean.text3}">
</h:inputText>
<hx:commandExButton type="button"
value="Submit"
id="button1"
styleClass="commandExButton">
<hx:behavior behaviorAction="get;stop"
event="onclick"
targetAction>="group1" >
</hx:behavior>
</hx:commandExButton>
<h:panelGroup id="group1" styleClass="panelGroup">
<h:outputText id="text4"
styleClass="outputText"
value="#{concatenatorBean.
concatenateThreeFields}">
</h:outputText>
</h:panelGroup>
<hx:ajaxRefreshSubmit id="ajaxRefreshSubmit1"
target="group1" >
</hx:ajaxRefreshSubmit>
</h:form>
</hx:scriptCollector>
</body>
</f:view>
Get External Content <hx:ajaxExternalRequest>

Click here for a larger image.


Click here for a larger image.

Click here for a larger image.
![]()
<f:view>
<body>
<hx:scriptCollector id="scriptCollector1">
<h:form id="form1" styleClass="form">
<hx:commandExButton type="submit"
value="Submit"
id="button1"
styleClass="commandExButton">
<hx:behavior event="onclick"
behaviorAction="get;stop"
targetAction="group1">
</hx:behavior>
</hx:commandExButton>
<h:panelGroup id="group1" styleClass="panelGroup">
<h:outputText id="text2"
styleClass="outputText"
value="External Page will be loaded here!">
</h:outputText>
</h:panelGroup>
<hx:ajaxExternalRequest id="ajaxExternalRequest1"
target="group1"
href="externalPage.faces"
source="group1">
</hx:ajaxExternalRequest>
</h:form>
</hx:scriptCollector>
</body>
</f:view>
Download Source Code Here
Reference
About the Author