Struts

Name:
Location: Bangalore, India

Thursday, January 31, 2008

Form Tag

<html:form action="/newRequest.do">


newRequest maps to the path attribute of Struts-config

<action
path="/app/newRequest"
attribute="RequestForm"
name="RequestForm"
scope="session"
validate="false"
input="searchRequestPage"
type="com.abc.ijk.projectName.action.ModuleName.NewRequestAction"<
<forward name="success" path="/jsp/request/jsp/Request.jsp" /<

Wednesday, January 30, 2008

Struts Tag - logic:iterate tag

<bean:message key="request.label.addtiInfo" bundle="abc"/>
<table >
<logic:present name="RequestForm" property="additionalInfoList">
<logic:iterate id="questionnaireBean" indexId="index" name="RequestForm" property="additionalInfoList">
<tr >
<td >
<%=index+1%>. <bean:write name="questionnaireBean" property="question"/><BR>
Response. <bean:write name="questionnaireBean" property="answer"/>
</td>
</tr>
</logic:iterate>
</logic:present>
</table>

Friday, January 04, 2008

Closing a pop-up window which has struts validation involved

I have a parent page which has a pop-up window. I have certain mandatory fields in the pop-up window which are validated by struts validation framework. The requirement is when user enters values for mandatory fields and click submit and if all the mandatory fields are populated with values then the pop-up window should close. Suppose if some of the mandatory fields are
not populated and user hits submit, this action results in validation errors and when there is validation error, the pop-up window should remain and not close.

For this we cannot write window.close() function in the onClick() event of the submit button. So what we have to do is in the struts mappings we need to forward to a new JSP page where will we be closing the pop-up window.

<body onload="window.close();"> ==> ClosePage.jsp


<!-- When user clicks on Submit button on the BankNameSearch.jsp -->
<action
path="/app/submitBank"
attribute="BankForm"
name="BankForm"
scope="session"
validate="true"
input="/jsp/common/jsp/BankNameSearch.jsp"
type="com.abc.xyz.applicationName.action.common.SubmitBankNameSearchAction">
<forward name="success" path="/jsp/common/jsp/ClosePage.jsp"/>
</action>

If we look at the above mapping we can find validation set to "true", Which means when there is any validation error it won't go any further till action class. But if there no validation error it will be forwarded to ClosePage.jsp where we will be closing the pop-up window.

Thursday, January 03, 2008

Tutorial

FAQ's
Tutorial - one
Tutorial - two


Action Chaining
Tutorial - three


Best Practices