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>
|
|