You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marcos Mendonça <ma...@gmail.com> on 2007/10/29 14:20:25 UTC

[struts2] s:generator not generating output

Hello

I'm using Struts2.0.9.
I have to generate a number o inputs acording to a parameter. I tried
using the Iterator Generator Tag on the Struts2 Showcase application,
but the output for me is nothing, null.

This is my jsp code:

    <s:generator val="" separator="," count="getGroupSize()">
        <s:iterator value="%{top}">
            <s:property />
            <s:textfield name="input" size="2" value="11">
        </s:iterator>
    </s:generator>

getGroupSize() is a method in the action that returns an int. I tested
it and is working properly.

What could be wrong, or where what should I look for to find out why
the generator is not working for me?

Any tips appreciated.

Thanks

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


Re: [struts2] s:generator not generating output

Posted by Dave Newton <ne...@yahoo.com>.
--- Marcos Mendonça <ma...@gmail.com> wrote:
> By the way how do I map many input text fields with
> the same name on the action side:

Well, your example only has one textfield named
"terminal", so you'd provide get/setTerminal methods.

If you want to map it to a collection then expose a
Collection named terminal.

http://struts.apache.org/2.x/docs/type-conversion.html

Towards the bottom it talks about Collection and Map
support.

d.

> 
> In this case, how do I match, this field on the
> action side:
> 
> <s:generator val="%{getTamanhoGrupo()}" separator=""
> count="%{getTamanhoGrupo()}">
>        <s:iterator value="%{top}">
>                    <s:textfield name="terminal"
> size="2" value="11">
>                    </s:textfield>
>        </s:iterator>
> </s:generator>
> 
> Thanks again!!
> 
> On 10/29/07, Dave Newton <ne...@yahoo.com>
> wrote:
> > --- Marcos Mendonça <ma...@gmail.com> wrote:
> > > Say I want to generate input fields and name
> them
> > > according to the iterator value. How would I do
> > that?
> > >
> > > <s:generator val="%{getTamanhoGrupo()}"
> separator=""
> > > count="%{getTamanhoGrupo()}">
> > >         <s:iterator value="%{top}">
> > >                   <s:textfield
> name="dynaField.area" size="2"
> > > value="11">
> > >                   </s:textfield>
> > >         </s:iterator>
> > > </s:generator>
> >
> > You'd probably just want to use the "status"
> attribute
> > of the <s:iterator...> tag and use it to build the
> > name of the text field, although you might want to
> > consider using array/map notation to clean things
> up
> > on the action side.
> >
> > d.
> >
> >
> >
>
---------------------------------------------------------------------
> > 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
> 
> 


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


Re: [struts2] s:generator not generating output

Posted by Marcos Mendonça <ma...@gmail.com>.
By the way how do I map many input text fields with the same name on
the action side:

In this case, how do I match, this field on the action side:

<s:generator val="%{getTamanhoGrupo()}" separator=""
count="%{getTamanhoGrupo()}">
       <s:iterator value="%{top}">
                   <s:textfield name="terminal" size="2" value="11">
                   </s:textfield>
       </s:iterator>
</s:generator>

Thanks again!!

On 10/29/07, Dave Newton <ne...@yahoo.com> wrote:
> --- Marcos Mendonça <ma...@gmail.com> wrote:
> > Say I want to generate input fields and name them
> > according to the iterator value. How would I do
> that?
> >
> > <s:generator val="%{getTamanhoGrupo()}" separator=""
> > count="%{getTamanhoGrupo()}">
> >         <s:iterator value="%{top}">
> >                   <s:textfield name="dynaField.area" size="2"
> > value="11">
> >                   </s:textfield>
> >         </s:iterator>
> > </s:generator>
>
> You'd probably just want to use the "status" attribute
> of the <s:iterator...> tag and use it to build the
> name of the text field, although you might want to
> consider using array/map notation to clean things up
> on the action side.
>
> d.
>
>
> ---------------------------------------------------------------------
> 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


Re: [struts2] s:generator not generating output

Posted by Dave Newton <ne...@yahoo.com>.
--- Marcos Mendonça <ma...@gmail.com> wrote:
> Say I want to generate input fields and name them
> according to the iterator value. How would I do
that?
> 
> <s:generator val="%{getTamanhoGrupo()}" separator=""
> count="%{getTamanhoGrupo()}">
>         <s:iterator value="%{top}">
> 		    <s:textfield name="dynaField.area" size="2"
> value="11">
> 		    </s:textfield>
>         </s:iterator>
> </s:generator>

You'd probably just want to use the "status" attribute
of the <s:iterator...> tag and use it to build the
name of the text field, although you might want to
consider using array/map notation to clean things up
on the action side.

d.


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


Re: [struts2] s:generator not generating output

Posted by Marcos Mendonça <ma...@gmail.com>.
Yes, I realized that after I posted the question.

generator working ok now...

Thanks, just one more question:

Say I want to generate input fields and name them according to the
iterator value. How would I do that?

<s:generator val="%{getTamanhoGrupo()}" separator=""
count="%{getTamanhoGrupo()}">
        <s:iterator value="%{top}">
		    <s:textfield name="dynaField.area" size="2" value="11">
		    </s:textfield>
        </s:iterator>
</s:generator>

I'd like to create each field with names say area1, area2, area3.

On 10/29/07, Dave Newton <ne...@yahoo.com> wrote:
> --- Marcos Mendonça <ma...@gmail.com> wrote:
> >     <s:generator val="" separator=","
>
> Isn't the "val" attribute what's parsed to create the
> iterator?
>
> d.
>
>
> ---------------------------------------------------------------------
> 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


Re: [struts2] s:generator not generating output

Posted by Dave Newton <ne...@yahoo.com>.
--- Marcos Mendonça <ma...@gmail.com> wrote:
>     <s:generator val="" separator=","

Isn't the "val" attribute what's parsed to create the
iterator?

d.


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