You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Allen Gilliland <al...@sun.com> on 2007/05/01 04:16:54 UTC
[s2] is there an equivalent for the old html:multibox tag?
Is there a direct equivalent struts2 tag to the struts1 html:multibox
tag? I am looking at some old code being migrated and i'm not sure how
best to accomplish the same thing in struts2 ...
<c:forEach var="foo" items="fooItems">
<html:multibox property="fooList">
<c:out property="${foo.id}"/>
</html:multibox>
</c:forEach>
that code iterates over a collection of foo objects and the multibox
makes checkboxes for each item in the list but knows how to only check
the ones that are included in 'fooList'.
looking at the struts2 tags I don't see an equivalent so is my only
option to use the s:checkbox tag?
-- Allen
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
[s2] Form/action data binding not working
Posted by Luciano Costa <mo...@gmail.com>.
Hi!
I'm trying to use a submit button outside the form I want to submit, but
it's not working.
<@s.submit
type="submit"
theme="ajax"
label="Salvar"
targets="divNewsForm"
formId="formNews"
href="${urlNewsForm_Save}" />
In this case I want to submit the "formNews" form.
Att,
Luciano Costa
monttez.com
-----Mensagem original-----
De: Allen.T.Gilliland@sun.com [mailto:Allen.T.Gilliland@sun.com] Em nome de
Allen Gilliland
Enviada em: quarta-feira, 2 de maio de 2007 12:01
Para: Struts Users Mailing List
Assunto: Re: [s2] is there an equivalent for the old html:multibox tag?
In case someone else is trying to do the same thing, here is the
solution I came up with. Using a multiple s:checkbox instances with a
name that points to a String[] did not give the results I wanted so I
had to bag that idea. Instead I did this ...
Action:
private String[] deleteIds = new String[0];
public String[] getDeleteIds();
public void setDeleteIds(String[] ids);
Jsp:
<s:iterator id="entry" value="someCollectionOfObjects">
<s:checkboxlist name="deleteIds" list="{#entry}" listKey="id" />
// do any other work using #entry
</s:iterator>
with this I can call getDeleteIds() in my action after a submit and it
will return a String[] of all ids that were checked for deletion. also,
when the form is being populated in the jsp it will automatically check
the box for each entry that had its id in the deleteIds array, so if
there is a submission error then the checkboxes are properly repopulated.
the only downside so far is that s:checkboxlist automatically creates a
label for each checkbox, which may not be desired. i am just using css
to "display:none" those labels as a work around, which isn't the best
case scenario, but it works.
-- Allen
Allen Gilliland wrote:
> Okay, I guess that s:checkbox can do what I want but I am having trouble
> getting the multiple values from the results of my checkboxes. So if I
> have this ...
>
> <s:iterator id="entry" value="myCollection">
> <s:checkbox name="deleteIds" fieldValue="%{entry.id}" />
> <s:checkbox name="disableIds" fieldValue="%{entry.id}" />
> </s:iterator>
>
> and in my action ...
>
> private String[] deleteIds = new String[0];
> public String[] getDeleteIds();
> public void setDeleteIds(String[] deleteIds);
> // same thing for disableIds
>
> I think that should work but I'm not getting the values that I expect.
> When I check only a single box it seems to submit values for both the
> delete and disabled boxes, and if I check multiple boxes I only get a
> single value.
>
> I am also curious why there are 2 inputs for my checkboxes ...
>
> <input type="checkbox" name="deleteIds"
> value="0112f2dd1248f33f011248f6bcb40004"
> id="globalCommentManagement_deleteIs"/>
> <input type="hidden" name="__checkbox_deleteIds"
> value="0112f2dd1248f33f011248f6bcb40004"/>
>
> is String[] the right type to use for collecting the values of the
> checkboxes? why am i not getting the multiple values and why are the 2
> checkboxes affecting each other?
>
> -- Allen
>
>
> Allen Gilliland wrote:
>> actually, I did have trouble getting it to work but it doesn't really
>> matter because that's not really what I am looking for. That tag will
>> create a whole list of checkboxes, but what I really need is to create
>> a single checkbox which is part of a list. It's a weird situation so
>> it wouldn't really surprise me if s2 didn't have support for it, but I
>> wanted to ask.
>>
>> in any case, the situation is that i am iterating over a collection
>> and displaying each entry in a list on the page. in that list i am
>> providing a couple of checkboxes which affect the status of that
>> entry, 1 which would delete the entry, the other which would set a
>> different status. so my basic code is ...
>>
>> <s:iterator list="myCollection">
>> <tr class="entry">
>> <td> // delete checkbox </td>
>> <td> // status checkbox </td>
>> <td> // print entry details </td>
>> </tr>
>> </s:iterator>
>>
>> so i'm not really trying to print a whole list of checkboxes, i'm
>> trying to print a single checkbox which is based on a list. it looks
>> like that's what the old html:multibox tag was for, but i dunno, i
>> didn't write the original code that i am updating :/
>>
>> -- Allen
>>
>>
>> Dave Newton wrote:
>>> --- Allen Gilliland <al...@sun.com> wrote:
>>>> Is there a direct equivalent struts2 tag to the
>>>> struts1 html:multibox tag? I am looking at some old
>>>
>>>> code being migrated and i'm not sure how best to accomplish the same
>>>> thing in struts2 ...
>>>
>>> Does <s:checkboxlist.../> not work for you?
>>>
>>> http://struts.apache.org/2.x/docs/checkboxlist.html
>>>
>>> d.
>>>
>>>
>>> __________________________________________________
>>> Do You Yahoo!?
>>> Tired of spam? Yahoo! Mail has the best spam protection around
>>> http://mail.yahoo.com
>>> ---------------------------------------------------------------------
>>> 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
>
---------------------------------------------------------------------
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: [s2] is there an equivalent for the old html:multibox tag?
Posted by Allen Gilliland <al...@sun.com>.
In case someone else is trying to do the same thing, here is the
solution I came up with. Using a multiple s:checkbox instances with a
name that points to a String[] did not give the results I wanted so I
had to bag that idea. Instead I did this ...
Action:
private String[] deleteIds = new String[0];
public String[] getDeleteIds();
public void setDeleteIds(String[] ids);
Jsp:
<s:iterator id="entry" value="someCollectionOfObjects">
<s:checkboxlist name="deleteIds" list="{#entry}" listKey="id" />
// do any other work using #entry
</s:iterator>
with this I can call getDeleteIds() in my action after a submit and it
will return a String[] of all ids that were checked for deletion. also,
when the form is being populated in the jsp it will automatically check
the box for each entry that had its id in the deleteIds array, so if
there is a submission error then the checkboxes are properly repopulated.
the only downside so far is that s:checkboxlist automatically creates a
label for each checkbox, which may not be desired. i am just using css
to "display:none" those labels as a work around, which isn't the best
case scenario, but it works.
-- Allen
Allen Gilliland wrote:
> Okay, I guess that s:checkbox can do what I want but I am having trouble
> getting the multiple values from the results of my checkboxes. So if I
> have this ...
>
> <s:iterator id="entry" value="myCollection">
> <s:checkbox name="deleteIds" fieldValue="%{entry.id}" />
> <s:checkbox name="disableIds" fieldValue="%{entry.id}" />
> </s:iterator>
>
> and in my action ...
>
> private String[] deleteIds = new String[0];
> public String[] getDeleteIds();
> public void setDeleteIds(String[] deleteIds);
> // same thing for disableIds
>
> I think that should work but I'm not getting the values that I expect.
> When I check only a single box it seems to submit values for both the
> delete and disabled boxes, and if I check multiple boxes I only get a
> single value.
>
> I am also curious why there are 2 inputs for my checkboxes ...
>
> <input type="checkbox" name="deleteIds"
> value="0112f2dd1248f33f011248f6bcb40004"
> id="globalCommentManagement_deleteIs"/>
> <input type="hidden" name="__checkbox_deleteIds"
> value="0112f2dd1248f33f011248f6bcb40004"/>
>
> is String[] the right type to use for collecting the values of the
> checkboxes? why am i not getting the multiple values and why are the 2
> checkboxes affecting each other?
>
> -- Allen
>
>
> Allen Gilliland wrote:
>> actually, I did have trouble getting it to work but it doesn't really
>> matter because that's not really what I am looking for. That tag will
>> create a whole list of checkboxes, but what I really need is to create
>> a single checkbox which is part of a list. It's a weird situation so
>> it wouldn't really surprise me if s2 didn't have support for it, but I
>> wanted to ask.
>>
>> in any case, the situation is that i am iterating over a collection
>> and displaying each entry in a list on the page. in that list i am
>> providing a couple of checkboxes which affect the status of that
>> entry, 1 which would delete the entry, the other which would set a
>> different status. so my basic code is ...
>>
>> <s:iterator list="myCollection">
>> <tr class="entry">
>> <td> // delete checkbox </td>
>> <td> // status checkbox </td>
>> <td> // print entry details </td>
>> </tr>
>> </s:iterator>
>>
>> so i'm not really trying to print a whole list of checkboxes, i'm
>> trying to print a single checkbox which is based on a list. it looks
>> like that's what the old html:multibox tag was for, but i dunno, i
>> didn't write the original code that i am updating :/
>>
>> -- Allen
>>
>>
>> Dave Newton wrote:
>>> --- Allen Gilliland <al...@sun.com> wrote:
>>>> Is there a direct equivalent struts2 tag to the
>>>> struts1 html:multibox tag? I am looking at some old
>>>
>>>> code being migrated and i'm not sure how best to accomplish the same
>>>> thing in struts2 ...
>>>
>>> Does <s:checkboxlist.../> not work for you?
>>>
>>> http://struts.apache.org/2.x/docs/checkboxlist.html
>>>
>>> d.
>>>
>>>
>>> __________________________________________________
>>> Do You Yahoo!?
>>> Tired of spam? Yahoo! Mail has the best spam protection around
>>> http://mail.yahoo.com
>>> ---------------------------------------------------------------------
>>> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [s2] is there an equivalent for the old html:multibox tag?
Posted by Allen Gilliland <al...@sun.com>.
Okay, I guess that s:checkbox can do what I want but I am having trouble
getting the multiple values from the results of my checkboxes. So if I
have this ...
<s:iterator id="entry" value="myCollection">
<s:checkbox name="deleteIds" fieldValue="%{entry.id}" />
<s:checkbox name="disableIds" fieldValue="%{entry.id}" />
</s:iterator>
and in my action ...
private String[] deleteIds = new String[0];
public String[] getDeleteIds();
public void setDeleteIds(String[] deleteIds);
// same thing for disableIds
I think that should work but I'm not getting the values that I expect.
When I check only a single box it seems to submit values for both the
delete and disabled boxes, and if I check multiple boxes I only get a
single value.
I am also curious why there are 2 inputs for my checkboxes ...
<input type="checkbox" name="deleteIds"
value="0112f2dd1248f33f011248f6bcb40004"
id="globalCommentManagement_deleteIs"/>
<input type="hidden" name="__checkbox_deleteIds"
value="0112f2dd1248f33f011248f6bcb40004"/>
is String[] the right type to use for collecting the values of the
checkboxes? why am i not getting the multiple values and why are the 2
checkboxes affecting each other?
-- Allen
Allen Gilliland wrote:
> actually, I did have trouble getting it to work but it doesn't really
> matter because that's not really what I am looking for. That tag will
> create a whole list of checkboxes, but what I really need is to create a
> single checkbox which is part of a list. It's a weird situation so it
> wouldn't really surprise me if s2 didn't have support for it, but I
> wanted to ask.
>
> in any case, the situation is that i am iterating over a collection and
> displaying each entry in a list on the page. in that list i am
> providing a couple of checkboxes which affect the status of that entry,
> 1 which would delete the entry, the other which would set a different
> status. so my basic code is ...
>
> <s:iterator list="myCollection">
> <tr class="entry">
> <td> // delete checkbox </td>
> <td> // status checkbox </td>
> <td> // print entry details </td>
> </tr>
> </s:iterator>
>
> so i'm not really trying to print a whole list of checkboxes, i'm trying
> to print a single checkbox which is based on a list. it looks like
> that's what the old html:multibox tag was for, but i dunno, i didn't
> write the original code that i am updating :/
>
> -- Allen
>
>
> Dave Newton wrote:
>> --- Allen Gilliland <al...@sun.com> wrote:
>>> Is there a direct equivalent struts2 tag to the
>>> struts1 html:multibox tag? I am looking at some old
>>
>>> code being migrated and i'm not sure how best to accomplish the same
>>> thing in struts2 ...
>>
>> Does <s:checkboxlist.../> not work for you?
>>
>> http://struts.apache.org/2.x/docs/checkboxlist.html
>>
>> d.
>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Tired of spam? Yahoo! Mail has the best spam protection around
>> http://mail.yahoo.com
>> ---------------------------------------------------------------------
>> 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: [s2] is there an equivalent for the old html:multibox tag?
Posted by Allen Gilliland <al...@sun.com>.
actually, I did have trouble getting it to work but it doesn't really
matter because that's not really what I am looking for. That tag will
create a whole list of checkboxes, but what I really need is to create a
single checkbox which is part of a list. It's a weird situation so it
wouldn't really surprise me if s2 didn't have support for it, but I
wanted to ask.
in any case, the situation is that i am iterating over a collection and
displaying each entry in a list on the page. in that list i am
providing a couple of checkboxes which affect the status of that entry,
1 which would delete the entry, the other which would set a different
status. so my basic code is ...
<s:iterator list="myCollection">
<tr class="entry">
<td> // delete checkbox </td>
<td> // status checkbox </td>
<td> // print entry details </td>
</tr>
</s:iterator>
so i'm not really trying to print a whole list of checkboxes, i'm trying
to print a single checkbox which is based on a list. it looks like
that's what the old html:multibox tag was for, but i dunno, i didn't
write the original code that i am updating :/
-- Allen
Dave Newton wrote:
> --- Allen Gilliland <al...@sun.com> wrote:
>> Is there a direct equivalent struts2 tag to the
>> struts1 html:multibox tag? I am looking at some old
>
>> code being migrated and i'm not sure how
>> best to accomplish the same thing in struts2 ...
>
> Does <s:checkboxlist.../> not work for you?
>
> http://struts.apache.org/2.x/docs/checkboxlist.html
>
> d.
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> 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: [s2] is there an equivalent for the old html:multibox tag?
Posted by Dave Newton <ne...@yahoo.com>.
--- Allen Gilliland <al...@sun.com> wrote:
> Is there a direct equivalent struts2 tag to the
> struts1 html:multibox tag? I am looking at some old
> code being migrated and i'm not sure how
> best to accomplish the same thing in struts2 ...
Does <s:checkboxlist.../> not work for you?
http://struts.apache.org/2.x/docs/checkboxlist.html
d.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org