Default selection using Struts html:select tag

L

Lucas White

Hi

I'm trying to default a combo box to select a default value when my
web page loads. The following code selects the index from the
indexList with index id 27 because I hard-coded it:

<html:select property="primaryIndexId" name="group" value="27">
<html:eek:ption value="-1">&nbsp;</html:eek:ption>
<html:eek:ptions collection="indexList" property="indexId"
labelProperty="indexDesc" />
</html:select>

But when I try to soft code it to display the group's primary index,
it does not work:

<html:select property="primaryIndexId" name="group"
value="primaryIndex.indexId">
<html:eek:ption value="-1">&nbsp;</html:eek:ption>
<html:eek:ptions collection="indexList" property="indexId"
labelProperty="indexDesc" />
</html:select>

Any help would be appreciated.
 
Y

Yan Lijun

you need not to code like that
<html:select property="primaryIndexId" name="group"
value="primaryIndex.indexId">
<html:eek:ption value="-1">&nbsp;</html:eek:ption>
<html:eek:ptions collection="indexList" property="indexId"
labelProperty="indexDesc" />
</html:select>

you simple only need to do is to set the property "primaryIndexId" in the
actionform to what you want it to be in the action servlet

ÔÚ 23 Apr 2004 14:02:09 -0700 ʱ, (e-mail address removed) (Lucas White) дÁË:
--
Hi

I'm trying to default a combo box to select a default value when my
web page loads. The following code selects the index from the
indexList with index id 27 because I hard-coded it:

<html:select property="primaryIndexId" name="group" value="27">
<html:eek:ption value="-1">&nbsp;</html:eek:ption>
<html:eek:ptions collection="indexList" property="indexId"
labelProperty="indexDesc" />
</html:select>

But when I try to soft code it to display the group's primary index,
it does not work:

<html:select property="primaryIndexId" name="group"
value="primaryIndex.indexId">
<html:eek:ption value="-1">&nbsp;</html:eek:ption>
<html:eek:ptions collection="indexList" property="indexId"
labelProperty="indexDesc" />
</html:select>

Any help would be appreciated.

(e-mail address removed)
/**
/* Java Is Not Platform-independent.It Is The Platform!
*/
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top