struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diego Manilla Suárez <diego.mani...@xeridia.com>
Subject Re: Problems initializing form objects
Date Tue, 14 Dec 2004 15:49:23 GMT
Hi Jeff, thanks for your answer. I was already doing that, using two 
actions (well, using two different methods of a LookupAction), one to 
initialize the list and the other to process it, but the problem arises 
when I submit the form in "page.jsp".

Jeff Beal wrote:

> When I have this sort of thing, I usually put it in an "initializer" 
> Action that I always link to in place of the JSP.
>
> <action path="initPage" name="BasicContentForm" validate="false" 
> type="com.example.InitAction">
>   <!-- This action populates the form -->
>   <forward path="page.jsp" redirect="false" name="success" />
> </action>
> <action path="processPage" name="BasicContentForm" validate="true" 
> input="initPage.do" ...>
>   <!-- this action processes the form -->
> </action>
>
> -- Jeff
>
> Diego Manilla Suárez wrote:
>
>> Hi! I have a problem with form members initialization.
>>
>> I have this form.
>>
>> public class BasicContentForm extends ValidatorForm {
>>
>>    protected java.util.List propertyValues;
>>      public BasicContentForm() {
>>        this.propertyValues = new java.util.ArrayList();
>>    }
>>      public void setPropertyValues( java.util.List propertyValues ) {
>>        this.propertyValues = propertyValues;
>>    }        public java.util.List getPropertyValues() {
>>        return this.propertyValues;
>>    }
>>      public Object getPropertyValue(int index) {
>>        return propertyValues.get(index);
>>    }
>>      public void reset(ActionMapping mapping, HttpServletRequest 
>> request) {
>>        this.propertyValues = new java.util.ArrayList();
>>    }
>> }
>>
>> And this jsp:
>>
>> <logic:iterate name="basicContentForm" property="propertyValues" 
>> id="propertyValue">
>> <html:text name="propertyValue" property="value" indexed="true"/>
>> </logic:iterate>
>>
>> The problem is that the number and type of the elements of 
>> propertyValues list is calculated dynamically (from the database). I 
>> was doing that on my Action class, but I've realized that this 
>> doesn't work: when I submit the form, I get an Exception at 
>> BeanUtils.populate, because the list is not properly initialized. If 
>> I can't initialize it on the reset() method (I need to access the 
>> database), what else can I do?
>>
>> Thanks in advance
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


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


Mime
View raw message