You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dirk Jaeckel <bi...@gate5.de> on 2001/09/14 15:26:04 UTC

multibox and reset()

Hi!


I am having trouble resetting a StringArray that is connected to a <html:multibox>-tag.

HTML-Example:

<html:form action="/map" method="GET">
	<html:multibox value="parking" property="layer"/>
	<html:multibox value="petrol" property="layer"/>

	<html:image property="layers" page="/img/update.gif"/>

</html:form>


Corresponding ActionForm:

public class MapForm extends ActionForm {

        private String[] _on = new String[0];

        public void reset() {
		_on = new String[0];
        }

        public void setLayer(String in) {
		_on = in;
        }

        public String[] getLayer() {
		return _on;
		
        }
}

The Manual told me to use the reset()-method to set The Array to the length 0, but reset() is never called.


Dirk


Re: multibox and reset()

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
reset is currently not called if <html:form> creates the form bean, which
happens if you go to the JSP page directly without hitting ActionServlet
first.

I've submitted a patch to fix this, but it has not been committed yet.

    Erik


----- Original Message -----
From: "Renaud Waldura" <re...@waldura.org>
To: <st...@jakarta.apache.org>
Cc: <bi...@gate5.de>
Sent: Friday, September 14, 2001 10:12 AM
Subject: Re: multibox and reset()


> The signature for reset() is the following:
>
> void reset(ActionMapping, HttpServletRequest)
>
> I don't know whether setting the array reference is null is enough, or you
> truly need to create a zero-length array like in your example below.
>
> I set mine to null, it seemed to work.
>
>
>
>
> ----- Original Message -----
> From: "Dirk Jaeckel" <bi...@gate5.de>
> To: <st...@jakarta.apache.org>
> Sent: Friday, September 14, 2001 6:26 AM
> Subject: multibox and reset()
>
>
> > Hi!
> >
> >
> > I am having trouble resetting a StringArray that is connected to a
> <html:multibox>-tag.
> >
> > HTML-Example:
> >
> > <html:form action="/map" method="GET">
> > <html:multibox value="parking" property="layer"/>
> > <html:multibox value="petrol" property="layer"/>
> >
> > <html:image property="layers" page="/img/update.gif"/>
> >
> > </html:form>
> >
> >
> > Corresponding ActionForm:
> >
> > public class MapForm extends ActionForm {
> >
> >         private String[] _on = new String[0];
> >
> >         public void reset() {
> > _on = new String[0];
> >         }
> >
> >         public void setLayer(String in) {
> > _on = in;
> >         }
> >
> >         public String[] getLayer() {
> > return _on;
> >
> >         }
> > }
> >
> > The Manual told me to use the reset()-method to set The Array to the
> length 0, but reset() is never called.
> >
> >
> > Dirk
> >
> >
>
>


Re: multibox and reset()

Posted by Renaud Waldura <re...@waldura.org>.
The signature for reset() is the following:

void reset(ActionMapping, HttpServletRequest)

I don't know whether setting the array reference is null is enough, or you
truly need to create a zero-length array like in your example below.

I set mine to null, it seemed to work.




----- Original Message -----
From: "Dirk Jaeckel" <bi...@gate5.de>
To: <st...@jakarta.apache.org>
Sent: Friday, September 14, 2001 6:26 AM
Subject: multibox and reset()


> Hi!
>
>
> I am having trouble resetting a StringArray that is connected to a
<html:multibox>-tag.
>
> HTML-Example:
>
> <html:form action="/map" method="GET">
> <html:multibox value="parking" property="layer"/>
> <html:multibox value="petrol" property="layer"/>
>
> <html:image property="layers" page="/img/update.gif"/>
>
> </html:form>
>
>
> Corresponding ActionForm:
>
> public class MapForm extends ActionForm {
>
>         private String[] _on = new String[0];
>
>         public void reset() {
> _on = new String[0];
>         }
>
>         public void setLayer(String in) {
> _on = in;
>         }
>
>         public String[] getLayer() {
> return _on;
>
>         }
> }
>
> The Manual told me to use the reset()-method to set The Array to the
length 0, but reset() is never called.
>
>
> Dirk
>
>