Jaffa Logo
 
SourceForge.net
Home Contact Us FAQs Site Map
Source Forge: Homepage Bugs @ Sourceforge Mailing Lists @ Sourceforge Task Manager @ Sourceforge CVS @ Sourceforge
Jaffa Site
Jaffa Runtime
Jaffa RAD
Sub-Projects
Using Struts Tags with JAFFA

This document give an overview of how normal STRUTS based tag libraries can be used with Jaffa, and the extra features that have been added to Jaffa to make this easier.

Normal Struts Use...

Typically when using struts forms, you specify the 'Action' in the form tag

<html:form method="POST" action="/SaveConnector">
      

And then to reference the for bean associated with the action you use the form name

<logic:equal name="connectorForm" property="adminAction" value="Create">
    <bean:message key="actions.connectors.create"/>
</logic:equal>
<logic:equal name="connectorForm" property="adminAction" value="Edit">
    <bean:write name="connectorForm" property="nodeLabel"/>
</logic:equal>
         

Inside the struts-config.xml you then associate the name of the FormBean with the 'Action' class.

<!-- Perform Save Connector transaction -->
<action
    path ="/SaveConnector"
    type ="org.apache.webapp.admin.connector.SaveConnectorAction"
    name ="connectorForm"
    input="/connector/connector.jsp" scope="session"
/>
          

Using Jaffa's 'TagHelper' Class

It can be quite tedious matching up the 'Action' and 'FormBean' names in the JSP, and can also be painful when you want to cut and paste common code between JSP's when each 'logic:', 'html:' or 'bean:' tag has to specifically reference the form name.

When you use the <Portlet:Form> tag from Jaffa (which extends the Struts <html:form> tag), you can then use the following code to get the 'FormName'. This code actually uses the 'struts-config.xml' to get the name based on the 'action' supplied in the <Portlet:Form> tag.

name='<%= TagHelper.getFormName(pageContext)%>'
      

Example

Struts vs Jaffa
<%@ page language="Java" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html locale="true">
<body bgcolor="white" background="../images/PaperTexture.gif">
<html:errors/>
<html:form method="POST" action="/SaveConnector">
    <logic:equal name="connectorForm" property="adminAction" value="Create">
        <bean:message key="actions.connectors.create"/>
    </logic:equal>
    <logic:equal name="connectorForm" property="adminAction" value="Edit">
        <bean:write name="connectorForm" property="nodeLabel"/>
    </logic:equal>
</html:form>
</body>
</html:html>
            
<%@ page language="java" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/jaffa-portlet.tld" prefix="Portlet" %>
<%@ page import="org.jaffa.presentation.portlet.widgets.taglib.TagHelper"%>

<html:html locale="true">
<body bgcolor="white" background="../images/PaperTexture.gif">
<html:errors/>
<Portlet:Form method="POST" action="/SaveConnector">
    <logic:equal name='<%=TagHelper.getFormName(pageContext)%>' property="adminAction" value="Create">
        <bean:message key="actions.connectors.create"/>
    </logic:equal>
    <logic:equal name='<%=TagHelper.getFormName(pageContext)%>' property="adminAction" value="Edit">
        <bean:write name='<%=TagHelper.getFormName(pageContext)%>' property="nodeLabel"/>
    </logic:equal>
</Portlet:Form>
</body>
</html:html>
          


File: withStruts.html, Last Modified: Tue Jun 24 2003 at 6:47:52pm. This site has been built using PPWIZARD