Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-taglibs Wiki" 
for change notification.

The following page has been changed by RahulAkolkar:
http://wiki.apache.org/jakarta-taglibs/ReusableDialogComponents/Tutorials/StrutsInterface

New page:
''Retrofit''

----

The RDC framework providing the user interface is completely agnostic to the 
higher layers of the (web) application framework. This flexibility allows RDCs 
to work in conjuction with any ''controller'' framework that the application 
author may choose to use. A commonly used web application framework is 
[http://struts.apache.org Struts] and the RDC distribution comes with helper 
JSP tags that define an interface contract bridging the RDC framework (our view 
layer) to Struts.

If you have used Struts, this JSP will look familiar:
{{{
10. <%@ page language="java" contentType="text/html" %>
20. <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
30
40. <html>
50.    <head>
60.      <title>Login</title>
70.    </head>
80.    <body bgcolor="white">
90.      <h3>Enter your login information:</h3>
100.         
110.     <html:errors/>
120.
130.     <form action="/login.do" method="post">
140.        
150.       Member Number:<input type="text" name="memberNumber"><br>
160.
170.       Security Code:<input type="password" name="securityCode"><br>
180.
190.       <input type="submit"><br>
200.
210.     </form>
220.   </body>
230. </html>
}}}

so will this form bean for the above JSP:
{{{
0.   // imports etc.
100. public class LoginForm extends ActionForm {
110.
120.    private String memberNumber;
130.    private String securityCode;
140.
150.    public String getMemberNumber() {
160.            return memberNumber;
170.    }
180.    public void setMemberNumber(String memberNumber) {
190.            this.memberNumber = memberNumber;
200.    }
210.    public String getSecurityCode() {
220.            return securityCode;
230.    }
240.    public void setSecurityCode(String securityCode) {
250.            this.securityCode = securityCode;
260.    }
270.
280.    public void reset(ActionMapping mapping,
290.                      HttpServletRequest request) {
300.            /** reset logic **/
310.    }
320.    public ActionErrors validate(ActionMapping mapping,
330.                                 HttpServletRequest request) {
340.            ActionErrors errors = new ActionErrors();
350.            /** validation logic **/
360.            return errors;
370.    }
380.
390. }
}}}


The above JSP that creates the login GUI ''roughly'' translates to this JSP for 
the login VUI (these are inherently different interaction paradigms, and 
comparison is often meaningless from an UI perspective -- the similarity is 
really from a ''task oriented'' perspective).
{{{
10.  <%@ page language="java" contentType="application/voicexml+xml" %>
20.  <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
30.  <%@ taglib prefix="rdc" uri="http://jakarta.apache.org/taglibs/rdc-1.0"%>
40.
50.  <vxml version="2.0" xml:lang="en-US"  xmlns="http://www.w3.org/2001/vxml";>
60.    <jsp:useBean id="dialogMap" class="java.util.LinkedHashMap" 
scope="session"/>
70.    <rdc:task map="${dialogMap}">
80.    
90.      <rdc:struts-errors />
100.
110.     <rdc:group id="login" 
strategy="org.apache.taglibs.rdc.dm.SimpleDirectedDialog" >
120.
130.       <rdc:digits id="memberNumber" minLength="2" maxLength="9"
140.        config="/config/member-number.xml" confirm="true" echo="true" />
150.
160.       <rdc:digits id="securityCode" minLength="2" maxLength="9"
170.        config="/config/mls-number.xml" confirm="true" echo="true" />
180.
190.     </rdc:group>
200.
210.   </rdc:task>
220. </vxml>
230.
240. <c:if test="${not empty login}">
250.   <rdc:struts-submit submit="/login.do" context="${pageContext}"
260.                      namelist="memberNumber securityCode" />
270. </c:if>
}}}

Other tutorials discuss most of the artifacts in this JSP. Lines 90 and 240-270 
are of particular interest for this discussion.

 * Since the RDC framework is server-side and the public data models of RDCs 
can be instances of an arbitrary Java class, the HTTP String based param name 
value pairs assumption does not hold. For example, a property of the form bean 
that corresponds to the value of a date RDC will be of type 
{{{java.util.Date}}} and so on. The population of the Action''''''Form instance 
is enabled by the {{{<rdc:struts-submit>}}} tag. The RDCs whose values need to 
be submitted are enumerated as a space separated namelist (line 260), where 
each token is an RDC ''id''. Since each RDC-based JSP might be invoked multiple 
times till all RDC artifacts on the host JSP complete their interactions, a 
{{{<rdc:struts-submit>}}} is wrapped in a condition that checks for ''page 
completion'' from a ''user task'' perspective.
 * The {{{<rdc:struts-errors>}}} tag plays out the error messages as VoiceXML 
prompts, rather than bulleted lists (or some other GUI variant). 

The only change to the Action''''''Form when moving to the RDC based JSP is the 
population of the form bean, which now occurs in the validate method (line 345 
below):
{{{
320.    public ActionErrors validate(ActionMapping mapping,
330.                                 HttpServletRequest request) {
340.            ActionErrors errors = new ActionErrors();
345.            StrutsSubmitTag.populate(this, request, errors);
350.            /** validation logic **/
360.            return errors;
370.    }
}}}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to