You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Laurie Harper <la...@holoweb.net> on 2006/12/05 01:59:58 UTC
Re: Pre-populated option values of a select not got on Submit
What do the 'category' property's getter and setter (getCategory and
setCategory methods) in the form bean look like?
L.
Sridhar Raman wrote:
> I have a select/option in my JSP like this:
> <html:select size="3" styleClass="menu" styleId="catsel"
> property="category"
> multiple="yes">
> <html:options collection="catSelList" labelProperty="displayName"
> property="id"/>
> </html:select>
>
> I have also defined the bean for catSelList:
> <bean:define id='catSelList' property='catSelList' name='editEPForm'/>
>
> In the Form java file, I have the method public Collection getCatSelList(),
> that returns the list of values that needs to be displayed in the
> select/option menu.
>
> The page works fine when opened. The values that need to be displayed in
> the
> options are displayed correctly. But the problem occurs on submit.
>
> Whatever I do, the property category (which refers to the html:select) is
> always null. Even if I add values from another list into this select/option
> menu, the value of category on submit is null. How do I rectify this
> problem?
>
> This is what I want - if the user doesn't change anything in that field,
> the
> pre-populated values needs to be stored under category. If he does change
> anything, the new values needs to be stored under category.
>
> How do I do this?
>
> Thanks,
> Sridhar
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Pre-populated option values of a select not got on Submit
Posted by Laurie Harper <la...@holoweb.net>.
Please keep discussion on the mailing list, so others have the chance
to respond and/or benefit. Comments in-line:
On 5-Dec-06, at 8:51 AM, Sridhar Raman wrote:
> This is how the the getter and setter of the category property
> looks like:
>
> public void setCategory(String[] category)
> {
> this.category = category;
> }
>
> /**
> * @return Returns the catlist.
> */
> public String[] getCatlist()
> {
> return catlist;
> }
The getter and setter names don't match here. Also, you're not using
the correct signatures for indexed properties. The following
documentation may help clarify things:
http://struts.apache.org/1.2.9/faqs/indexedprops.html
L.
> Apart from that I have this method to populate the category values:
> public Collection<HtmlSelectOption> getCatSelList()
> {
> RepoOperations ro = new RepoOperations();
> catSelList = null;
>
> try
> {
> catSelList = ro.getNodeIDs(session, category);
> }
> catch (Exception e)
> {
> System.err.println(e);
> }
> return catSelList;
> }
>
> What am I doing wrong?
>
> On 12/5/06, Laurie Harper < laurie@holoweb.net> wrote:
> What do the 'category' property's getter and setter (getCategory and
> setCategory methods) in the form bean look like?
>
> L.
>
> Sridhar Raman wrote:
> > I have a select/option in my JSP like this:
> > <html:select size="3" styleClass="menu" styleId="catsel"
> > property="category"
> > multiple="yes">
> > <html:options collection="catSelList" labelProperty="displayName"
> > property="id"/>
> > </html:select>
> >
> > I have also defined the bean for catSelList:
> > <bean:define id='catSelList' property='catSelList'
> name='editEPForm'/>
> >
> > In the Form java file, I have the method public Collection
> getCatSelList(),
> > that returns the list of values that needs to be displayed in the
> > select/option menu.
> >
> > The page works fine when opened. The values that need to be
> displayed in
> > the
> > options are displayed correctly. But the problem occurs on submit.
> >
> > Whatever I do, the property category (which refers to the
> html:select) is
> > always null. Even if I add values from another list into this
> select/option
> > menu, the value of category on submit is null. How do I rectify this
> > problem?
> >
> > This is what I want - if the user doesn't change anything in that
> field,
> > the
> > pre-populated values needs to be stored under category. If he
> does change
> > anything, the new values needs to be stored under category.
> >
> > How do I do this?
> >
> > Thanks,
> > Sridhar
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Laurie Harper
Open Source advocate, Java geek: http://www.holoweb.net/laurie
Founder, Zotech Software: http://www.zotechsoftware.com/