You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian Trzupek <bt...@mac.com> on 2007/05/09 00:06:53 UTC
Select Tag - Odd Behavior
I am using Struts 2 (tried 2.0.1-2.0.6) and am having bizarre
behavior with the select tag in a jsp page.
My code looks like this:
<s:form name="editCredential" action="step4">
....
<s:select list="credential.credentialGenerators"
emptyOption="true" listKey="name" listValue="name"/>
<s:submit value="%{getText('credwizard.step3.submit')}"
id="hider"/>
</s:form>
When I do this the list gets displayed with the fully qualified class
name of the bean with the ID, instead of the name and description
fields. (almost as if it can't find them)
My current work around is to create the select by hand with:
<s:form name="editCredential" action="step4">
....
<tr>
<td class="tdLabel"><label
for="step4_credential_generator" class="label"><s:text
name="credwizard.step3.generator"/></label></td>
<td>
<select name="credential.generator" id="step4_">
<s:iterator
value="credential.credentialGenerators">
<option value="<s:property value="name"/
>"><s:property value="name"/></option>
</s:iterator>
</select>
</td>
</tr>
<s:submit value="%{getText('credwizard.step3.submit')}"
id="hider"/>
</s:form>
--------------------
So my question is, why does the struts iterator tag perform the
traversal of the list correctly and the struts select tag does not?
Any advise on how to 'make it work' would be appreciated.
Oh and BTW I have several other selects in my app, and they all work
fine.
Thanks,
Brian-
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Select Tag - Odd Behavior
Posted by Brian Trzupek <bt...@mac.com>.
Laurie,
Yeah - Walking through code now. I will post back if I can resolve
this one.
b-
On May 9, 2007, at 9:56 PM, Laurie Harper wrote:
> The only thing I can think of is that the collection is of a type
> s:select doesn't support, or that the individual elements in the
> collection are not what you think they are. I can't see anything
> from the details you've posted that looks wrong.
>
> Maybe it would help to grab a copy of the Struts source code
> corresponding to the release you're using and step through the code
> to see what might be happening.
>
> L.
>
> Brian Trzupek wrote:
>> Laurie,
>> Here are some more details.
>> I have a collection of beans (simple pojo's - com.xyz.SomePojo )
>> that have a name and description field, both are strings. This is
>> what the 'credential.credentialGenerators' call returns.
>> If I use the S2 select tag the name and value for the option(s) in
>> that control will be like:
>> <option name="[com.xyz.SomePojo@F1A567]>[com.xyz.SomePojo@F1A567]</
>> option>
>> If I tear through that same list with the S2 Iterator then the
>> results are (correct):
>> <option name="Generator 1 Name">Generator 1 Name</option>
>> ....where the "Generator 1 Name" is the content of the actual
>> 'name' field from the Pojo set server side.
>> I hope this helps a bit, as I am stumped. Especially since I have
>> other select tags working correctly.
>> Thanks,
>> Brian
>> On May 9, 2007, at 12:45 AM, Laurie Harper wrote:
>>> Brian Trzupek wrote:
>>>> I am using Struts 2 (tried 2.0.1-2.0.6) and am having bizarre
>>>> behavior with the select tag in a jsp page.
>>>> My code looks like this:
>>>> <s:form name="editCredential" action="step4">
>>>> ....
>>>> <s:select list="credential.credentialGenerators"
>>>> emptyOption="true" listKey="name" listValue="name"/>
>>>> <s:submit value="%{getText('credwizard.step3.submit')}"
>>>> id="hider"/>
>>>> </s:form>
>>>> When I do this the list gets displayed with the fully qualified
>>>> class name of the bean with the ID, instead of the name and
>>>> description fields. (almost as if it can't find them)
>>>
>>> I'm not sure what you mean; do you get a list of options where
>>> the rendered 'id' attribute is incorrect? the rendered value is
>>> incorrect? or just a single option element? What description
>>> fields? It would be helpful to include a sample of what you're
>>> seeing rendered vs. what you were expecting to see.
>>>
>>>> My current work around is to create the select by hand with:
>>>> <s:form name="editCredential" action="step4">
>>>> ....
>>>> <tr>
>>>> <td class="tdLabel"><label
>>>> for="step4_credential_generator" class="label"><s:text
>>>> name="credwizard.step3.generator"/></label></td>
>>>> <td>
>>>> <select name="credential.generator" id="step4_">
>>>> <s:iterator
>>>> value="credential.credentialGenerators">
>>>> <option value="<s:property value="name"/
>>>> >"><s:property value="name"/></option>
>>>> </s:iterator>
>>>> </select>
>>>> </td>
>>>> </tr>
>>>> <s:submit value="%{getText('credwizard.step3.submit')}"
>>>> id="hider"/>
>>>> </s:form>
>>>> --------------------
>>>> So my question is, why does the struts iterator tag perform the
>>>> traversal of the list correctly and the struts select tag does
>>>> not? Any advise on how to 'make it work' would be appreciated.
>>>
>>> What type does the getCredentialGenerators() method return? And,
>>> assuming it's some sort of collection, what do the elements look
>>> like? I can't think of any reason off hand why the first code
>>> snippet would fail and the second work, but without seeing more
>>> of your code or understanding exactly *how* the first snippet
>>> fails, it's tough to diagnose.
>>>
>>> L.
>>>
>>>
>>> --------------------------------------------------------------------
>>> -
>>> 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: Select Tag - Odd Behavior
Posted by Laurie Harper <la...@holoweb.net>.
The only thing I can think of is that the collection is of a type
s:select doesn't support, or that the individual elements in the
collection are not what you think they are. I can't see anything from
the details you've posted that looks wrong.
Maybe it would help to grab a copy of the Struts source code
corresponding to the release you're using and step through the code to
see what might be happening.
L.
Brian Trzupek wrote:
> Laurie,
>
> Here are some more details.
>
> I have a collection of beans (simple pojo's - com.xyz.SomePojo ) that
> have a name and description field, both are strings. This is what the
> 'credential.credentialGenerators' call returns.
>
> If I use the S2 select tag the name and value for the option(s) in that
> control will be like:
> <option name="[com.xyz.SomePojo@F1A567]>[com.xyz.SomePojo@F1A567]</option>
>
> If I tear through that same list with the S2 Iterator then the results
> are (correct):
> <option name="Generator 1 Name">Generator 1 Name</option>
>
> ....where the "Generator 1 Name" is the content of the actual 'name'
> field from the Pojo set server side.
>
> I hope this helps a bit, as I am stumped. Especially since I have other
> select tags working correctly.
>
> Thanks,
> Brian
>
>
> On May 9, 2007, at 12:45 AM, Laurie Harper wrote:
>
>> Brian Trzupek wrote:
>>> I am using Struts 2 (tried 2.0.1-2.0.6) and am having bizarre
>>> behavior with the select tag in a jsp page.
>>> My code looks like this:
>>> <s:form name="editCredential" action="step4">
>>> ....
>>> <s:select list="credential.credentialGenerators"
>>> emptyOption="true" listKey="name" listValue="name"/>
>>> <s:submit value="%{getText('credwizard.step3.submit')}"
>>> id="hider"/>
>>> </s:form>
>>> When I do this the list gets displayed with the fully qualified class
>>> name of the bean with the ID, instead of the name and description
>>> fields. (almost as if it can't find them)
>>
>> I'm not sure what you mean; do you get a list of options where the
>> rendered 'id' attribute is incorrect? the rendered value is incorrect?
>> or just a single option element? What description fields? It would be
>> helpful to include a sample of what you're seeing rendered vs. what
>> you were expecting to see.
>>
>>> My current work around is to create the select by hand with:
>>> <s:form name="editCredential" action="step4">
>>> ....
>>> <tr>
>>> <td class="tdLabel"><label
>>> for="step4_credential_generator" class="label"><s:text
>>> name="credwizard.step3.generator"/></label></td>
>>> <td>
>>> <select name="credential.generator" id="step4_">
>>> <s:iterator value="credential.credentialGenerators">
>>> <option value="<s:property
>>> value="name"/>"><s:property value="name"/></option>
>>> </s:iterator>
>>> </select>
>>> </td>
>>> </tr>
>>> <s:submit value="%{getText('credwizard.step3.submit')}"
>>> id="hider"/>
>>> </s:form>
>>> --------------------
>>> So my question is, why does the struts iterator tag perform the
>>> traversal of the list correctly and the struts select tag does not?
>>> Any advise on how to 'make it work' would be appreciated.
>>
>> What type does the getCredentialGenerators() method return? And,
>> assuming it's some sort of collection, what do the elements look like?
>> I can't think of any reason off hand why the first code snippet would
>> fail and the second work, but without seeing more of your code or
>> understanding exactly *how* the first snippet fails, it's tough to
>> diagnose.
>>
>> L.
>>
>>
>> ---------------------------------------------------------------------
>> 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: Select Tag - Odd Behavior
Posted by Brian Trzupek <bt...@mac.com>.
Laurie,
Here are some more details.
I have a collection of beans (simple pojo's - com.xyz.SomePojo ) that
have a name and description field, both are strings. This is what the
'credential.credentialGenerators' call returns.
If I use the S2 select tag the name and value for the option(s) in
that control will be like:
<option name="[com.xyz.SomePojo@F1A567]>[com.xyz.SomePojo@F1A567]</
option>
If I tear through that same list with the S2 Iterator then the
results are (correct):
<option name="Generator 1 Name">Generator 1 Name</option>
...where the "Generator 1 Name" is the content of the actual 'name'
field from the Pojo set server side.
I hope this helps a bit, as I am stumped. Especially since I have
other select tags working correctly.
Thanks,
Brian
On May 9, 2007, at 12:45 AM, Laurie Harper wrote:
> Brian Trzupek wrote:
>> I am using Struts 2 (tried 2.0.1-2.0.6) and am having bizarre
>> behavior with the select tag in a jsp page.
>> My code looks like this:
>> <s:form name="editCredential" action="step4">
>> ....
>> <s:select list="credential.credentialGenerators"
>> emptyOption="true" listKey="name" listValue="name"/>
>> <s:submit value="%{getText('credwizard.step3.submit')}"
>> id="hider"/>
>> </s:form>
>> When I do this the list gets displayed with the fully qualified
>> class name of the bean with the ID, instead of the name and
>> description fields. (almost as if it can't find them)
>
> I'm not sure what you mean; do you get a list of options where the
> rendered 'id' attribute is incorrect? the rendered value is
> incorrect? or just a single option element? What description
> fields? It would be helpful to include a sample of what you're
> seeing rendered vs. what you were expecting to see.
>
>> My current work around is to create the select by hand with:
>> <s:form name="editCredential" action="step4">
>> ....
>> <tr>
>> <td class="tdLabel"><label
>> for="step4_credential_generator" class="label"><s:text
>> name="credwizard.step3.generator"/></label></td>
>> <td>
>> <select name="credential.generator" id="step4_">
>> <s:iterator
>> value="credential.credentialGenerators">
>> <option value="<s:property value="name"/
>> >"><s:property value="name"/></option>
>> </s:iterator>
>> </select>
>> </td>
>> </tr>
>> <s:submit value="%{getText('credwizard.step3.submit')}"
>> id="hider"/>
>> </s:form>
>> --------------------
>> So my question is, why does the struts iterator tag perform the
>> traversal of the list correctly and the struts select tag does
>> not? Any advise on how to 'make it work' would be appreciated.
>
> What type does the getCredentialGenerators() method return? And,
> assuming it's some sort of collection, what do the elements look
> like? I can't think of any reason off hand why the first code
> snippet would fail and the second work, but without seeing more of
> your code or understanding exactly *how* the first snippet fails,
> it's tough to diagnose.
>
> L.
>
>
> ---------------------------------------------------------------------
> 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: Select Tag - Odd Behavior
Posted by Laurie Harper <la...@holoweb.net>.
Brian Trzupek wrote:
> I am using Struts 2 (tried 2.0.1-2.0.6) and am having bizarre behavior
> with the select tag in a jsp page.
>
> My code looks like this:
>
> <s:form name="editCredential" action="step4">
> ....
> <s:select list="credential.credentialGenerators"
> emptyOption="true" listKey="name" listValue="name"/>
>
> <s:submit value="%{getText('credwizard.step3.submit')}"
> id="hider"/>
> </s:form>
>
> When I do this the list gets displayed with the fully qualified class
> name of the bean with the ID, instead of the name and description
> fields. (almost as if it can't find them)
I'm not sure what you mean; do you get a list of options where the
rendered 'id' attribute is incorrect? the rendered value is incorrect?
or just a single option element? What description fields? It would be
helpful to include a sample of what you're seeing rendered vs. what you
were expecting to see.
> My current work around is to create the select by hand with:
>
> <s:form name="editCredential" action="step4">
> ....
> <tr>
> <td class="tdLabel"><label for="step4_credential_generator"
> class="label"><s:text name="credwizard.step3.generator"/></label></td>
> <td>
> <select name="credential.generator" id="step4_">
> <s:iterator value="credential.credentialGenerators">
> <option value="<s:property
> value="name"/>"><s:property value="name"/></option>
> </s:iterator>
> </select>
> </td>
> </tr>
> <s:submit value="%{getText('credwizard.step3.submit')}"
> id="hider"/>
> </s:form>
>
> --------------------
>
> So my question is, why does the struts iterator tag perform the
> traversal of the list correctly and the struts select tag does not? Any
> advise on how to 'make it work' would be appreciated.
What type does the getCredentialGenerators() method return? And,
assuming it's some sort of collection, what do the elements look like? I
can't think of any reason off hand why the first code snippet would fail
and the second work, but without seeing more of your code or
understanding exactly *how* the first snippet fails, it's tough to diagnose.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: OptionTransfer Select - id number formatting
Posted by Brian Trzupek <bt...@mac.com>.
I figured this out.
All I did was change the method signature on my Action class from:
setNotificationUsers(Collection notificationUsers)
to
setNotificationUsers(Collection<Integer> notificationUsers)
And Struts/XWork took care of the rest.
Brian-
On May 31, 2007, at 10:08 AM, Brian Trzupek wrote:
> I am using the optionTransferSelect tag all over the place, love
> this control!
>
> Anyways, when the id property of list (which is an int) gets
> displayed in the HTML by the tag the number get formatted with a
> comma when the numbers get into 4+ digits.
>
> Example output:
>
> <option value="2,451">email@email.com</option>
>
> <option value="2,452">email2@email.com</option>
>
> When the list is set on my Action class the values come back as
> strings with the comma in it and then when I pass them to my DAO it
> fails to load b/c it is not parsing the number ( new Integer
> (value) ) correctly.
>
> My question is, why is the control outputting a 'formatted' number?
> and is there a way to 'turn that off'?
>
> I would prefer a solution that will globally tell the tag to render
> the values without the formatting, rather than have to parse them
> in every action where I have a list coming back in.
>
> Any Ideas?
>
> Thanks Brian-
>
> --- Here is my jsp tag ----
>
> <s:optiontransferselect
> label="%{getText('item.notifications')}"
> name="leftsidesystemUsers"
> rightTitle="Users Notified"
> leftTitle="System User List"
> list="%{systemUsers}"
> listValue="email"
> listKey="id"
> allowAddToLeft="true"
> allowAddAllToLeft="true"
> allowUpDownOnLeft="true"
>
> multiple="true"
> headerKey="headerKey"
> headerValue="--- Please Select ---"
> emptyOption="true"
> doubleId="id"
> doubleList="%{notificationUsers}"
> doubleListValue="email"
> doubleListKey="id"
> doubleName="notificationUsers"
> doubleHeaderKey="doubleHeaderKey"
> doubleHeaderValue="--- Please Select ---"
> doubleEmptyOption="true"
> doubleMultiple="true"
> />
>
> ---------------------------------------------------------------------
> 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: OptionTransfer Select - id number formatting
Posted by Al Sutton <al...@al-and-andrea.org.uk>.
Had the same problem recently, the choice I made was to make the parameter
for the second action the same type as the parameter for the first, i.e.;
ActionA has public Integer getValue()
ActionB has public setValue(Integer x)
Worked for me with Longs.
-----Original Message-----
From: Brian Trzupek [mailto:btrzupek43@mac.com]
Sent: 31 May 2007 16:08
To: Struts Users Mailing List
Subject: OptionTransfer Select - id number formatting
I am using the optionTransferSelect tag all over the place, love this
control!
Anyways, when the id property of list (which is an int) gets displayed in
the HTML by the tag the number get formatted with a comma when the numbers
get into 4+ digits.
Example output:
<option value="2,451">email@email.com</option>
<option value="2,452">email2@email.com</option>
When the list is set on my Action class the values come back as strings with
the comma in it and then when I pass them to my DAO it fails to load b/c it
is not parsing the number ( new Integer(value) ) correctly.
My question is, why is the control outputting a 'formatted' number?
and is there a way to 'turn that off'?
I would prefer a solution that will globally tell the tag to render the
values without the formatting, rather than have to parse them in every
action where I have a list coming back in.
Any Ideas?
Thanks Brian-
--- Here is my jsp tag ----
<s:optiontransferselect
label="%{getText('item.notifications')}"
name="leftsidesystemUsers"
rightTitle="Users Notified"
leftTitle="System User List"
list="%{systemUsers}"
listValue="email"
listKey="id"
allowAddToLeft="true"
allowAddAllToLeft="true"
allowUpDownOnLeft="true"
multiple="true"
headerKey="headerKey"
headerValue="--- Please Select ---"
emptyOption="true"
doubleId="id"
doubleList="%{notificationUsers}"
doubleListValue="email"
doubleListKey="id"
doubleName="notificationUsers"
doubleHeaderKey="doubleHeaderKey"
doubleHeaderValue="--- Please Select ---"
doubleEmptyOption="true"
doubleMultiple="true"
/>
---------------------------------------------------------------------
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
OptionTransfer Select - id number formatting
Posted by Brian Trzupek <bt...@mac.com>.
I am using the optionTransferSelect tag all over the place, love this
control!
Anyways, when the id property of list (which is an int) gets
displayed in the HTML by the tag the number get formatted with a
comma when the numbers get into 4+ digits.
Example output:
<option value="2,451">email@email.com</option>
<option value="2,452">email2@email.com</option>
When the list is set on my Action class the values come back as
strings with the comma in it and then when I pass them to my DAO it
fails to load b/c it is not parsing the number ( new Integer(value) )
correctly.
My question is, why is the control outputting a 'formatted' number?
and is there a way to 'turn that off'?
I would prefer a solution that will globally tell the tag to render
the values without the formatting, rather than have to parse them in
every action where I have a list coming back in.
Any Ideas?
Thanks Brian-
--- Here is my jsp tag ----
<s:optiontransferselect
label="%{getText('item.notifications')}"
name="leftsidesystemUsers"
rightTitle="Users Notified"
leftTitle="System User List"
list="%{systemUsers}"
listValue="email"
listKey="id"
allowAddToLeft="true"
allowAddAllToLeft="true"
allowUpDownOnLeft="true"
multiple="true"
headerKey="headerKey"
headerValue="--- Please Select ---"
emptyOption="true"
doubleId="id"
doubleList="%{notificationUsers}"
doubleListValue="email"
doubleListKey="id"
doubleName="notificationUsers"
doubleHeaderKey="doubleHeaderKey"
doubleHeaderValue="--- Please Select ---"
doubleEmptyOption="true"
doubleMultiple="true"
/>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org