You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by SivaK <ks...@yahoo.co.in> on 2008/10/31 14:39:18 UTC

validating and retrieving collection of objects

Hi,

I am using Struts 1.2.9. I have an issue with validation and retrieval of
collection of objects from form. Form is in session scope. Form has an VO
object list along with other fields.

In action class i got the list of classes and set in the form variable
listClass. In jsp page i iterate it and show it. WaivedInd is displayed as
checkbox and paidBy is displayed as dropdown.(options Student,School,Govt).
I have no issues in displaying this.
But when i change the value in the dropdown, i dont get the updated value in
the action. Also how to validate this when i didn't select any value in the
dropdown. The fees list size will vary.

ActionForm

private List<ClassVO> listClass;

.....
.....


Structure of ClassVO object


public class ClassVO{

 private string a;

 private String b;

 private List<FeeVO> listFees;

//getters and setters

}

Structure of FeeVO

public class FeeVO{

	private String feeName;

	private String feeValue;

	private boolean waivedInd;

	private String paidBy;

//getters and setters
}

JSP code

<logic:iterate id="fees" name="SchoolForm" property="voClass.listFees">
        <tr>
	<td class="dataItemLpad"><bean:write name="fees" property="feeName"/></td>
	<td><bean:write name="fees" property="feeValue"/></td>
	<td>
	       <c:choose>
		<c:when test="${fees.groupCode=='GOVERNMENT'}">
                              Govt. fee
		</c:when>
		<c:when test="${fees.groupCode=='STUDENT'}">
		    Student fee
		</c:when>
	       <c:otherwise>
		<html:multibox property="waivedIdArray" name="ScenarioForm"
onclick="javascript:fnCalculateTotalCost(this);" title="Waived Ind">
		<bean:write property="feeValue" name="fees" />@#<bean:write
property="feeName" name="fees" />									
		</html:multibox>
	      </c:otherwise>
	   </c:choose>							
            </td>
	<td class="RightPad">
	    <logic:equal name="fees" value="D" property="paidByInd" >
	    <html:select property="paidBy" name="fees">
		<html:option value="">--Select--</html:option>
		<html:optionsCollection property="mapPaidBy" name="fees" label="value"
value="key"/>
	    </html:select>	
	   </logic:equal>		
	   <logic:equal value="L" property="paidByInd" name="fees">
		<bean:write name="fees" property="paidBy"/>
	   </logic:equal>				
	</td>
          </tr>
          <tr height="1px" valign="top">
	<td colspan="4" class="extratbrow"></td>
          </tr>
</logic:iterate>

Thank you,

Regards,
Siva
-- 
View this message in context: http://www.nabble.com/validating-and-retrieving-collection-of-objects-tp20266167p20266167.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: validating and retrieving collection of objects

Posted by Paweł Wielgus <po...@gmail.com>.
Hi SivaK,
i don't remember good, but there is something called "indexed" in
html:text for example, try googling with "struts indexed properties".

Best greetings,
Paweł Wielgus.

2008/10/31 SivaK <ks...@yahoo.co.in>:
>
> Hi,
>
> I am using Struts 1.2.9. I have an issue with validation and retrieval of
> collection of objects from form. Form is in session scope. Form has an VO
> object list along with other fields.
>
> In action class i got the list of classes and set in the form variable
> listClass. In jsp page i iterate it and show it. WaivedInd is displayed as
> checkbox and paidBy is displayed as dropdown.(options Student,School,Govt).
> I have no issues in displaying this.
> But when i change the value in the dropdown, i dont get the updated value in
> the action. Also how to validate this when i didn't select any value in the
> dropdown. The fees list size will vary.
>
> ActionForm
>
> private List<ClassVO> listClass;
>
> .....
> .....
>
>
> Structure of ClassVO object
>
>
> public class ClassVO{
>
>  private string a;
>
>  private String b;
>
>  private List<FeeVO> listFees;
>
> //getters and setters
>
> }
>
> Structure of FeeVO
>
> public class FeeVO{
>
>        private String feeName;
>
>        private String feeValue;
>
>        private boolean waivedInd;
>
>        private String paidBy;
>
> //getters and setters
> }
>
> JSP code
>
> <logic:iterate id="fees" name="SchoolForm" property="voClass.listFees">
>        <tr>
>        <td class="dataItemLpad"><bean:write name="fees" property="feeName"/></td>
>        <td><bean:write name="fees" property="feeValue"/></td>
>        <td>
>               <c:choose>
>                <c:when test="${fees.groupCode=='GOVERNMENT'}">
>                              Govt. fee
>                </c:when>
>                <c:when test="${fees.groupCode=='STUDENT'}">
>                    Student fee
>                </c:when>
>               <c:otherwise>
>                <html:multibox property="waivedIdArray" name="ScenarioForm"
> onclick="javascript:fnCalculateTotalCost(this);" title="Waived Ind">
>                <bean:write property="feeValue" name="fees" />@#<bean:write
> property="feeName" name="fees" />
>                </html:multibox>
>              </c:otherwise>
>           </c:choose>
>            </td>
>        <td class="RightPad">
>            <logic:equal name="fees" value="D" property="paidByInd" >
>            <html:select property="paidBy" name="fees">
>                <html:option value="">--Select--</html:option>
>                <html:optionsCollection property="mapPaidBy" name="fees" label="value"
> value="key"/>
>            </html:select>
>           </logic:equal>
>           <logic:equal value="L" property="paidByInd" name="fees">
>                <bean:write name="fees" property="paidBy"/>
>           </logic:equal>
>        </td>
>          </tr>
>          <tr height="1px" valign="top">
>        <td colspan="4" class="extratbrow"></td>
>          </tr>
> </logic:iterate>
>
> Thank you,
>
> Regards,
> Siva
> --
> View this message in context: http://www.nabble.com/validating-and-retrieving-collection-of-objects-tp20266167p20266167.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>