struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "fea jabi" <zy...@hotmail.com>
Subject Re: FW: html:text
Date Wed, 12 Jul 2006 12:37:36 GMT
Thankyou very much for your responce.


>From: Laurie Harper <laurie@holoweb.net>
>Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
>To: user@struts.apache.org
>Subject: Re: FW: html:text
>Date: Tue, 11 Jul 2006 17:32:55 -0400
>
> > <form-bean name="Form"
> > type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
> >            <form-property name="AdHrs" type="java.util.ArrayList"/>
>
>So your form bean defines only one property, named AdHrs, which is a list 
>of values.
>
> > <html:form action="DispatchHoursAction.do" method="post">
> >   <display:table name="sessionScope.Form.AdHrs" id="rows"
> >       requestURI="PrepareAction.do" >
> >     <display:column titleKey="lbl.hrs">
> >       <c:if test="${rows.Hrs != null}">
> >         <html:text name="rows" property="Hrs"
> >             errorStyleClass="errormsg"/>
> >       </c:if>
> >     </display:column>
> >   </display:table>
> > </html:form>
>
>You're using display:table to expose each entry in the list as a scripting 
>variable rows, so rows is a bean of whatever type is stored in the AdHrs 
>property, and you're binding the html:text element to the Hrs property of 
>that bean.
>
>Note that you have, at this point, broken the link between the form bean 
>and the property; Struts has no way to know that the thing referenced by 
>the html:text tag is a property on the form once the request is submitted.
>
>What you probably want here is something like <html:text 
>property="AdHrs[${rownum}].Hrs" value="${rows.Hrs}"/> -- the property name 
>needs to name a property on the form bean. You'll have to consult 
>display:table's documentation to figure out how to get rownum.
>
> >        <form name="Form">
> >            <field property="hrs" depends="integer,validwhen">
>
>This applies a validation rule to the property 'hrs' on the form bean Form. 
>As noted above, the only property you've defined is AdHrs. According to 
>your code, that property holds a list of beans which have a property named 
>Hrs (not hrs).
>
>I'm not sure off hand how to specify validation rules for indexed 
>properties, but at the very least you'll need to reference the nested 
>property correctly.
>
>L.
>
>fea jabi wrote:
>>
>>Thanks for your response.
>>have a table
>>
>>in one of the columns have <html:text>. not all rows have the <html:text>.
>>
>>need to validate the user entered values in the <html:text> using 
>>validator.xml.
>>
>>Created an object.java file which holds the row data of the table.  
>>Created a list of these row objects and stored as a form property.
>>
>>Not sure how to proceed now. should I put the List as a property in the 
>>form-bean?? if I did so how will the user edited <html:text> updated to 
>>the list so that I can do validations?
>>
>>Using the below the table is filled with the right values but when the 
>>user entered values i nthe input fields the form property hrs has previous 
>>values itself and does not validate right as it doesn't have the user 
>>entered values.
>>
>>need help with this.
>>
>>Struts Config:
>><form-bean name="Form" 
>>type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
>>            <form-property name="AdHrs" type="java.util.ArrayList"/>
>>..........................
>>...................
>></form-bean>
>>
>><action
>>            path="/PrepareAction"
>>            type="com.actions.PrepareAction"
>>            name="Form"
>>            scope="session"
>>            validate="false"
>>            input="/pages/Hours.jsp">
>>            <forward name="success" path="/pages/Hours.jsp" 
>>redirect="false"/>
>>        </action>
>>
>>        <action
>>            path="/DispatchHoursAction"
>>            type="com.actions.DispatchHoursAction"
>>            name="Form"
>>            scope="session"
>>            validate="true"
>>            input="/pages/Hours.jsp"
>>            parameter="method">
>>            <forward name="successSave" path="/PrepareAction.do" 
>>redirect="false"/>
>>            <forward name="successRefresh" path="/PrepareAction.do" 
>>redirect="false"/>
>>            <forward name="successPrev" path="/PrepareCustAction.do" 
>>redirect="false"/>
>>            <forward name="successNext" path="/PrepareLoanAction.do" 
>>redirect="false"/>
>>        </action>
>>
>>JSP:
>><html:form action="DispatchHoursAction.do" method="post">
>>.....................
>><display:table name="sessionScope.Form.AdHrs" id="rows"
>>requestURI="PrepareAction.do" >
>>.........................
>>......................
>><display:column titleKey="lbl.hrs">
>>        <c:if test="${rows.Hrs != null}">
>>               <html:text name="rows" property="Hrs"
>>errorStyleClass="errormsg"/>
>>         </c:if>
>></display:column>
>></display:table>
>></html:form>
>>
>>Validation.xml
>>
>><formset>
>>        <form name="Form">
>>            <field property="hrs" depends="integer,validwhen">
>>                <msg name="integer" key="lbl.notvalidnumber"/>
>>                <msg name="validwhen" key="lbl.notvalidnumber"/>
>>                <var>
>>                    <var-name>test</var-name>
>>                    <var-value>(*this* >= 0)</var-value>
>>                </var>
>>            </field>
>>        </form>
>>    </formset>
>>
>>
>>
>>
>>
>>>From: Laurie Harper <laurie@holoweb.net>
>>>Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
>>>To: user@struts.apache.org
>>>Subject: Re: FW: html:text
>>>Date: Thu, 06 Jul 2006 14:36:27 -0400
>>>
>>>Does the 'Form' form bean have a property 'hrs'? How is it declared? What 
>>>is the type and base type (parent class) of the form bean? We really need 
>>>to see the relevant parts of your struts-config.xml (form bean 
>>>declaration and action mappings) to tell what's happening.
>>>
>>>L.
>>>
>>>fea jabi wrote:
>>>>can somene help me with this please?
>>>>
>>>>how to do validation in validator.xml
>>>>
>>>><formset>
>>>>        <form name="Form">
>>>>            <field property="hrs" depends="integer,validwhen">
>>>>                <msg name="integer" key="lbl.notvalidnumber"/>
>>>>                <msg name="validwhen" key="lbl.notvalidnumber"/>
>>>>                <var>
>>>>                    <var-name>test</var-name>
>>>>                    <var-value>(*this* >= 0)</var-value>
>>>>                </var>
>>>>            </field>
>>>>        </form>
>>>>    </formset>
>>>>
>>>>Where hrs is the attribute in the row object of the table. Even when I 
>>>>enter string value in the text field I see no error messages.
>>>>
>>>>
>>>>>From: "fea jabi" <zyxrm@hotmail.com>
>>>>>Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
>>>>>To: user@struts.apache.org
>>>>>Subject: html:text
>>>>>Date: Wed, 05 Jul 2006 15:36:47 -0400
>>>>>
>>>>>In a table in one of the columns there are <html:text>
>>>>>
>>>>>is it required that each input item has a corresponding form-bean 
>>>>>property?
>>>>>
>>>>>
>>>>>by using the below does it take all the user entered values in the 
>>>>>column??
>>>>>
>>>>>Each row is an object and sessionScope.Form.hrs is the list of these 
>>>>>objects.
>>>>>
>>>>><display:table name="sessionScope.Form.hrs" id="rows" 
>>>>>requestURI="PrepareAction.do" >
>>>>>........................
>>>>>.....................
>>>>><display:column titleKey="lbl.hrs">
>>>>>        <c:if test="${rows.hrs != null}">
>>>>>               <html:text name="rows" property="hrs" 
>>>>>errorStyleClass="errormsg"/>
>>>>>         </c:if>
>>>>></display:column>
>>>>></display:table>
>>>>>
>>>>>Thanks.
>>>>>
>>>>>_________________________________________________________________
>>>>>Donít just search. Find. Check out the new MSN Search! 
>>>>>http://search.msn.click-url.com/go/onm00200636ave/direct/01/
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>>For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>
>>>>_________________________________________________________________
>>>>Express yourself instantly with MSN Messenger! Download today - it's 
>>>>FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>For additional commands, e-mail: user-help@struts.apache.org
>>>
>>
>>_________________________________________________________________
>>Express yourself instantly with MSN Messenger! Download today - it's FREE! 
>>http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


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


Mime
View raw message