You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bOOyah <bo...@nowhere.org> on 2004/03/30 04:20:30 UTC
Losing my mind: why can't my JSP use the getter on my form bean??
Hi guys
I've got a simple form bean and a simpler JSP. I can get the JSP to
pull some values from the form bean but not others, and I cannot figure
out why.
I want to display Select menus in a variable number of rows. I managed
to figure out indexed properties (at loooooooooong last) and so the
html:select tags are working. It's just the html:optionsCollection tag
that I can't figure out.
Here's the Form (trimmed for brevity; the two private members are
populated okay by other methods):
8<-----------------------------------------------------
public class MyForm extends ActionForm
{
private Integer selectedIdTvSystem[];
private List picklistTvSystem;
// return the user's previously selected TV system
public Integer getSelectedIdTvSystem(int loopIndex) {
...
}
// set the user's newly selected TV system
public void setSelectedIdTvSystem(int loopIndex, Integer selectedId) {
...
}
// get the drop-down list of TV choices for the user
public List getPicklistTvSystem() {
return this.picklistTvSystem;
}
// set the list of possible TV choices for the user
public void setPicklistTvSystem(List picklistTvSystem) {
this.picklistTvSystem = picklistTvSystem;
}
}
8<-----------------------------------------------------
Here's the JSP tester. It's a Mickey Mouse loop to display two
drop-down picklists. The indexed property referenced in the
'html:select' seems to work fine. But the 'html:optionsCollection' tag
isn't finding the 'picklistTvSystem' property on the form.
8<-----------------------------------------------------
<c:forEach begin="0" end="1" varStatus="status">
<jsp:useBean id="status"
type="javax.servlet.jsp.jstl.core.LoopTagStatus"/>
<html:select property="selectedIdTvSystem[${status.count - 1}]" >
<html:optionsCollection name="picklistTvSystem"
value="id"
label="value" />
</html:select>
</c:forEach>
8<-----------------------------------------------------
Tomcat throws this exception:
javax.servlet.jsp.JspException: Cannot find bean picklistTvSystem in
any scope
at
org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:938)
Any help will be gratefully received.
--
Sean.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Losing my mind: why can't my JSP use the getter on my form bean??
Posted by bOOyah <bo...@nowhere.org>.
bOOyah wrote:
> <html:optionsCollection name="picklistTvSystem"
> value="id"
> label="value" />
For crying out loud. No sooner had I clicked the 'Send' button on my
mailer when I spotted the bug. For those few of you still wiping the
tears from your eyes, the 'name' attribute above should, of course, have
been 'property'.
I've been staring at that little time sink all day.
--
Sean.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org