The documentation for html:select states that, 'This tag is only valid
when nested inside a form tag body.' It *might* work without an
enclosing html:form tag, but you would need to tell the
html:optionsCollection tag where to lookup the 'system_href' property.
Try adding name="availableSystem" to the html:optionsCollection tag.
I'm not sure why you're using html:select / html:optionsCollection
without an enclosing form in the first place, though. What use is a
select list outside a form?
L.
Leung Ping Cheung wrote:
Should the jsp be tied to a form for this case?
I do not make up a form.
I do this in the jsp.
<%
List availableSystemList =
UserSystemService.getInstance().getAvailableSystemList(request.getRemoteUser());
request.setAttribute("availableSystem", availableSystemList);
%>
<html:select property="availableSystem">
<html:optionsCollection property="system_href"/>
</html:select>
where system_href is one of the attributes of availableSystem.
I get the error message of
ERROR - Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Cannot find bean under name
org.apache.struts.taglib.html.BEAN
at
org.apache.struts.taglib.html.SelectTag.calculateMatchValues(SelectTag.java:240)
at
org.apache.struts.taglib.html.SelectTag.doStartTag(SelectTag.java:200)
at
org.apache.jsp.user.assignUserSystem_jsp._jspx_meth_html_select_0(org.apache.jsp.user.assignUserSystem_jsp:123)
at
org.apache.jsp.user.assignUserSystem_jsp._jspService(org.apache.jsp.user.assignUserSystem_jsp:82)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
On 12/8/05, Keith Sader <[EMAIL PROTECTED]> wrote:
You need to make use of the html:optionsCollection tag
<html:select property="yearOfManufacture">
<html:optionsCollection property="years"/>
</html:select>
In your form bean you need an object that has the properties label and
value. Like this:
public class ComboBoxItem implements Serializable, Comparable {
private String label;
private String value;
// This is the contract for html:optionsCollection, label is what is
// displayed on the form, and value is the code behind it.
public ComboBoxItem(String label, String value) {
this.label = label;
this.value = value;
}
public String getLabel() {
return label;
}
public String getValue() {
return value;
}
public int compareTo(Object o) {...}
Then, in your populate action, you'll set a Collection<ComboBoxItem>
on the form. That should to it.
On 12/8/05, Leung Ping Cheung <[EMAIL PROTECTED]> wrote:
I think there are many people asking the same question. But I cannot
find the answer. any web sites have more or less coding example of
populating a dropdown box or list in a Struts way before the web page
displays.
Thanks
--
Keith Sader
[EMAIL PROTECTED]
http://www.saderfamily.org/roller/page/ksader
http://www.jroller.com/page/certifieddanger
---------------------------------------------------------------------
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]