You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Lukas Latz <lu...@gmx.de> on 2004/05/18 14:54:52 UTC
initialize Collection for html-tags options tag - HOW?
Hi list
I'm trying to use the options tag and am stuck with this problem:
I hold all 'Model' information in a single model object in the HttpSession.
Initialization for the Collection used by the <options> , held in an
ActionForm, must come from there (first time the view that uses that form is
displayed).
I'd have loved populate the Collection in the ActionForm, like so:
if(this.getSearches() == null){
ArrayList al = new ArrayList();
Search[] ss = model.getSearches();
for( int i=0; i<ss.length; i++){
Search s = ss[i];
al.add(s);
}
this.setSearches(al);
}
if(this.getCurrSearch() == null){
this.setCurrSearch( model.getSearches()[0] );
}
... where 'model' comes from the session.
Problem: I can't seem to reach the session from the ActionForm.
I then resorted to do the populating from the associated action, where
reaching the session is no problem, BUT: the action that's associated with
this form (to deal with its values when the user enters something) is not
the action that first leads to the view (JSP) that uses that form.
The action that does lead to that view is associated with a different
ActionForm (obviously), so I can't use it to populate it with init values.
I'm considering forwarding from Action to Action, but I'm wondering if
that's the right way to do it.
--
NEU : GMX Internet.FreeDSL
Ab sofort DSL-Tarif ohne Grundgeb�hr: http://www.gmx.net/dsl
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: initialize Collection for html-tags options tag - HOW?
Posted by Lukas Latz <lu...@gmx.de>.
An update:
My attempt to forward from action to action failed.
These are the mappings for the actions involved.
<action path="/multi" type="bla.presentation.MultiAction" name="multiForm" >
<forward name="layer" path="/pages/multi_layer.jsp"/>
<forward name="findname" path="/pages/multi_findname.jsp"/>
<forward name="findaddress" path="/pages/multi_findaddress.jsp"/>
<forward name="comment" path="/pages/multi_comment.jsp"/>
</action>
<action path="/multi/findname" type="bla.presentation.MultiFindNameAction"
name="multiFindNameForm" >
<forward name="findname" path="/pages/multi_findname.jsp"/>
</action>
I tried to replace
<forward name="findname" path="/pages/multi_findname.jsp"/>
with
<forward name="findname" path="/multi/findname.do"/>
but somehow the MultiFindNameAction's execute method is apparently called
with the ActionForm param set to null:
"No getter method available for property layerId for bean under name null"
This seems to indicate that that's not proper way to do
initialization--which is OK, as it's the Action's job to handle user input,
not to preprocess the Form bean.
So, back to square one: what's the proper way to get init values from a
Model object that's held in the session into an ActionForm?
--
NEU : GMX Internet.FreeDSL
Ab sofort DSL-Tarif ohne Grundgeb�hr: http://www.gmx.net/dsl
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org