problem of <html:select> in struts

Hello,

I have data like this

IDErrorParam

1Net

2Refund

3Published

I want to render in html like this

<select name="error">

<option value="1">Net</option>

<option value="2">Refund</option>

<option value="3">Published</option>

</select >

How can i do it.I would be appriciate If anyone could let me know what is the solution of this problem. Please Send me ASAP.

My code is as follows

In action class

PreparedStatement StatementGetErrorParam = ConnGetErrorParam.prepareStatement("SELECT * FROM tblQCErrorParameter",ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);

ResultSet GetErrorParam = StatementGetErrorParam.executeQuery();

boolean GetErrorParam_isEmpty = !GetErrorParam.next();

boolean GetErrorParam_hasData = !GetErrorParam_isEmpty;

Object GetErrorParam_data;

int GetErrorParam_numRows = 0;

GetErrorParam.beforeFirst();

ArrayList displayErrorParamList=new ArrayList();

while(GetErrorParam.next())

{

displayErrorParamList.add(GetErrorParam.getString("ErrorParameter"));

}

((QualityForm)form).setDisplayErrorParamList(displayErrorParamList);

I tried in my jsp like this

<html:select property="errorParam">

<html:options property="displayErrorParamList" name="QualityForm"/>

</html:select>

Then in Html i am getting like this

<select name="errorParam">

<option value="Net">Net</option>

<option value="Refunds">Refunds</option>

<option value="Published">Published</option>

</select>

I want here value 1,2 and 3.

Thanks

Rajnish Kushwaha

[1821 byte] By [rajnishsunjavaa] at [2007-10-2 16:06:24]
# 1

So you need to retrieve the values 1,2,3 and pass them along as well.

Probably best way is to have an object

public class ErrorParam{

private int id;

private String name;

}

You then in your loop:

while(GetErrorParam.next())

{

ErrorParam errorParam = new ErrorParam(GetErrorParam.getInt("ErrorParameterId"), GetErrorParam.getString("ErrorParameter"));

displayErrorParamList.add(errorParam);

}

and then change your struts html:options tag to use a property and labelProperty attributes.

http://struts.apache.org//struts-doc-1.2.8/userGuide/struts-html.html#options

evnafetsa at 2007-7-13 16:45:07 > top of Java-index,Java Essentials,New To Java...