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 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/security-code.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.

The only change to the ActionForm 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.    }

ReusableDialogComponents/Tutorials/StrutsInterface (last edited 2009-09-20 22:14:03 by localhost)