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="[EMAIL PROTECTED]>[EMAIL PROTECTED]</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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]