Streuts: html:select not being updated properly in DynaActionValidatorForm

  • Thread starter Thomas 'Skip' Hollowell
  • Start date
T

Thomas 'Skip' Hollowell

<html:form action="dynAdminGroupMaint">
<html:select property="parmGroup" onchange="this.form.submit();">
<option>
<c:forEach var="group" items="${allGroups}">
<option value="<c:eek:ut value="${group.id}"/>">
<c:eek:ut value="${group.name}"/>
</option>
</c:forEach>
</html:select>
</html:form>

I would expect that the select is not being upated with the selected
value because I am not using an <html:eek:ption> tag, just the plain
<option> tag. But I get errors out the wazoo when I try the following:

<html:eek:ption value="<c:eek:ut value="${group.id}"/>">
<c:eek:ut value="${group.name}"/>
</html:eek:ption>

It does not like the ${group_id} in the option value parameter.

Any ideas how I can get around this? I want to parse the list and
display the list values in the select box, and then after submitting the
form, display ther select box with the selected value higglighted.

Thanks

Skip.
 
S

Sudsy

Thomas said:
<html:form action="dynAdminGroupMaint">
<html:select property="parmGroup" onchange="this.form.submit();">
<option>
<c:forEach var="group" items="${allGroups}">
<option value="<c:eek:ut value="${group.id}"/>">
<c:eek:ut value="${group.name}"/>
</option>
</c:forEach>
</html:select>
</html:form>

Grouping is wrong. Note the beginning and end tags of the option:
one is outside the loop while the other is inside.
I would expect that the select is not being upated with the selected
value because I am not using an <html:eek:ption> tag, just the plain
<option> tag. But I get errors out the wazoo when I try the following:

<html:eek:ption value="<c:eek:ut value="${group.id}"/>">
<c:eek:ut value="${group.name}"/>
</html:eek:ption>

You're nesting quotes. Try this:
<html:eek:ption value='<c:eek:ut value="${group.id}"/>' >
(or swap the single and double quotes and try again)

For more sophisticated apps, try this article:
<http://www.sudsy.net/technology/struts-advanced.html>
 
T

Thomas 'Skip' Hollowell

Sudsy said:
Grouping is wrong. Note the beginning and end tags of the option:
one is outside the loop while the other is inside.

The grouping is ok, I have one blank option in there (no close option
tag) and then the options with data.The quoting was a bit doubled up, but changing the inner double quotes
to singles didn't help, or changing the outers. I have a feeling there
is a more straightforward way to tackle something like this, but I just
can't grasp it at the moment. I have bookmarked your page though, it
has quite a few nice tricks to remember.
 
D

David W. Burhans

Sudsy said:
Grouping is wrong. Note the beginning and end tags of the option:
one is outside the loop while the other is inside.

Although the grouping is wrong, it has no bearing on the problem.
Instead, you must make sure that the form bean for the
"dynaAdminGroupMain" action includes a property that is the same name
as the select element property.

You might also use the the struts <html:eek:ptionsCollection> tag instead
of the said:
You're nesting quotes. Try this:
<html:eek:ption value='<c:eek:ut value="${group.id}"/>' >
(or swap the single and double quotes and try again)

The quotes are in no way nested. Note that the <c:eek:ut> thingy inside
the option value attribute is a JSP tag and will be processed before
the HTML is sent to the client (i.e. the double quotes around the
${group.id} reference will not be present when the HTML is processed
by the client).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top