You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marcello Savino <Ma...@aldebra.com> on 2007/04/10 17:01:51 UTC
Aray of Bean and optionsCollection
Hi all, i've the following problem using the tag <html:optionsCollection
Let's say this is my code (actionForm, jsp, bean class)
public class MyForm extends ActionForm {
private myBean[] arrayOfMyBean;
public void reset(ActionMapping mapping, HttpServletRequest
request){
arrayOfMyBean=someClass.getMyBeanArray();
request.setAttribute("aBean", arrayOfMyBean);
super.reset( mapping, request);
}
}
______________________________________________________
The jsp:
<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html:xhtml />
<html:html locale="true">
<body>
<html:form action="/MyAction">
<html:select property="myBeanCode" >
<html:optionsCollection property="aBean" value="code"
label="descr"/>
</html:select>
</html:form>
</body>
</html:html>
________________________________________________________
myBean Class:
public class myBean implements java.io.Serializable{
private Integer code;
private String descr;
public Integer getCode(){return code;}
public String getDescr(){return descr;}
public void setCode(Integer val){ code=val;}
public void setDescr(String val){ descr=val;}
}
_________________________________________________________
When i open the jsp i got the following Error:
org.apache.jasper.JasperException: No bean specified
Could anyone help me?
Any help will be greatly appreciated.
Thanks in advance
Marcello
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: R: Array of Bean and optionsCollection (up)
Posted by Laurie Harper <la...@holoweb.net>.
Marcello Savino wrote:
>> At first sight, u miss the name of the collection in "
>> <html:optionsCollection property="aBean" value="code"
>> label="descr"/>"
> Do you mean i have to specify the attribute name="aBean"instead of
> property="aBean" ?
You only need to specify the 'name' attribute if you want to specify a
bean other than the form bean. Assuming the data you want to reference
is in the form bean, as in your case, you only need to specify the
'property' attribute.
>> second u forgot the dot in myBeanCode , it's myBean.code , Struts will
> do myBean.getCode().
> myBeanCode is only a name for the current bean in the select tag
The 'property' attribute on the select tag should name a property in
your form bean. That tells Struts where to store/retrieve the associated
value (current selection).
>> third : your form property "aBean" is an array & u use a select ( which
> a single property)
> Do you mean i have to specify the attribute name="aBean"instead of
> property="aBean" ?
You need *two* properties on your form bean: one to hold the list of
options, which you have (the 'aBean' property); and one to hold the
value that's actually selected. The html:select tag's 'property'
attribute should reference the second one:
public class MyForm extends ActionForm {
private myBean[] arrayOfMyBean;
private String selectedValue;
public myBean[] getABean() {return arrayOfMyBean;}
public String getSelectedValue() {return selectedValue;}
public String setSelectedValue(String val) {
selectedValue = val;}
}
<html:select property="selectedValue" >
<html:optionsCollection property="aBean"
value="code" label="descr"/>
</html:select>
L.
> Thanks for your attention
>
>
>
> 2007/4/11, Marcello Savino <Ma...@aldebra.com>:
>> Please excuse me but i try again ... (hope will never die)
>>
>> Hi all, i've the following problem using the tag
>> <html:optionsCollection, the jsp give the following error:
>> org.apache.jasper.JasperException: No bean specified
>>
>> Let's say this is my code (actionForm, jsp, bean class)
>>
>> public class MyForm extends ActionForm {
>> private myBean[] arrayOfMyBean;
>> public void reset(ActionMapping mapping, HttpServletRequest
>> request){
>> arrayOfMyBean=someClass.getMyBeanArray();
>> request.setAttribute("aBean", arrayOfMyBean);
>> super.reset( mapping, request);
>> }
>> public myBean[] getABean(return arrayOfMyBean); // i forgot
>> this on my previous post, not on my code!
>> }
>> ______________________________________________________
>>
>> The jsp:
>>
>> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:xhtml
>
>> /> <html:html locale="true"> <body> <html:form action="/MyAction">
>> <html:select property="myBeanCode" >
>> <html:optionsCollection property="aBean" value="code"
>> label="descr"/>
>> </html:select>
>> </html:form>
>> </body>
>> </html:html>
>> ________________________________________________________
>>
>> myBean Class:
>>
>> public class myBean implements java.io.Serializable{
>> private Integer code;
>> private String descr;
>>
>> public Integer getCode(){return code;}
>> public String getDescr(){return descr;}
>>
>> public void setCode(Integer val){ code=val;}
>> public void setDescr(String val){ descr=val;} }
>>
>> _________________________________________________________
>>
>>
>> Could anyone help me?
>> Any help will be greatly appreciated.
>> Thanks in advance
>> Marcello
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
R: Array of Bean and optionsCollection (up)
Posted by Marcello Savino <Ma...@aldebra.com>.
>At first sight, u miss the name of the collection in "
><html:optionsCollection property="aBean" value="code"
>label="descr"/>"
Do you mean i have to specify the attribute name="aBean"instead of
property="aBean" ?
>second u forgot the dot in myBeanCode , it's myBean.code , Struts will
do myBean.getCode().
myBeanCode is only a name for the current bean in the select tag
>third : your form property "aBean" is an array & u use a select ( which
a single property)
Do you mean i have to specify the attribute name="aBean"instead of
property="aBean" ?
Thanks for your attention
2007/4/11, Marcello Savino <Ma...@aldebra.com>:
>
> Please excuse me but i try again ... (hope will never die)
>
> Hi all, i've the following problem using the tag
> <html:optionsCollection, the jsp give the following error:
> org.apache.jasper.JasperException: No bean specified
>
> Let's say this is my code (actionForm, jsp, bean class)
>
> public class MyForm extends ActionForm {
> private myBean[] arrayOfMyBean;
> public void reset(ActionMapping mapping, HttpServletRequest
> request){
> arrayOfMyBean=someClass.getMyBeanArray();
> request.setAttribute("aBean", arrayOfMyBean);
> super.reset( mapping, request);
> }
> public myBean[] getABean(return arrayOfMyBean); // i forgot
> this on my previous post, not on my code!
> }
> ______________________________________________________
>
> The jsp:
>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:xhtml
> /> <html:html locale="true"> <body> <html:form action="/MyAction">
> <html:select property="myBeanCode" >
> <html:optionsCollection property="aBean" value="code"
> label="descr"/>
> </html:select>
> </html:form>
> </body>
> </html:html>
> ________________________________________________________
>
> myBean Class:
>
> public class myBean implements java.io.Serializable{
> private Integer code;
> private String descr;
>
> public Integer getCode(){return code;}
> public String getDescr(){return descr;}
>
> public void setCode(Integer val){ code=val;}
> public void setDescr(String val){ descr=val;} }
>
> _________________________________________________________
>
>
> Could anyone help me?
> Any help will be greatly appreciated.
> Thanks in advance
> Marcello
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Array of Bean and optionsCollection (up)
Posted by Romu <ro...@gmail.com>.
At first sight, u miss the name of the collection in "
<html:optionsCollection property="aBean" value="code"
label="descr"/>"
second u forgot the dot in myBeanCode , it's myBean.code , Struts will do
myBean.getCode().
third : your form property "aBean" is an array & u use a select ( which a
single property)
not clear but i could have understood wrong .
Good luck
2007/4/11, Marcello Savino <Ma...@aldebra.com>:
>
> Please excuse me but i try again ... (hope will never die)
>
> Hi all, i've the following problem using the tag
> <html:optionsCollection, the jsp give the following error:
> org.apache.jasper.JasperException: No bean specified
>
> Let's say this is my code (actionForm, jsp, bean class)
>
> public class MyForm extends ActionForm {
> private myBean[] arrayOfMyBean;
> public void reset(ActionMapping mapping, HttpServletRequest
> request){
> arrayOfMyBean=someClass.getMyBeanArray();
> request.setAttribute("aBean", arrayOfMyBean);
> super.reset( mapping, request);
> }
> public myBean[] getABean(return arrayOfMyBean); // i forgot this
> on my previous post, not on my code!
> }
> ______________________________________________________
>
> The jsp:
>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:xhtml
> /> <html:html locale="true"> <body> <html:form action="/MyAction">
> <html:select property="myBeanCode" >
> <html:optionsCollection property="aBean" value="code"
> label="descr"/>
> </html:select>
> </html:form>
> </body>
> </html:html>
> ________________________________________________________
>
> myBean Class:
>
> public class myBean implements java.io.Serializable{
> private Integer code;
> private String descr;
>
> public Integer getCode(){return code;}
> public String getDescr(){return descr;}
>
> public void setCode(Integer val){ code=val;}
> public void setDescr(String val){ descr=val;} }
>
> _________________________________________________________
>
>
> Could anyone help me?
> Any help will be greatly appreciated.
> Thanks in advance
> Marcello
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Array of Bean and optionsCollection (up)
Posted by Marcello Savino <Ma...@aldebra.com>.
Please excuse me but i try again ... (hope will never die)
Hi all, i've the following problem using the tag
<html:optionsCollection, the jsp give the following error:
org.apache.jasper.JasperException: No bean specified
Let's say this is my code (actionForm, jsp, bean class)
public class MyForm extends ActionForm {
private myBean[] arrayOfMyBean;
public void reset(ActionMapping mapping, HttpServletRequest
request){
arrayOfMyBean=someClass.getMyBeanArray();
request.setAttribute("aBean", arrayOfMyBean);
super.reset( mapping, request);
}
public myBean[] getABean(return arrayOfMyBean); // i forgot this
on my previous post, not on my code!
}
______________________________________________________
The jsp:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <html:xhtml
/> <html:html locale="true"> <body> <html:form action="/MyAction">
<html:select property="myBeanCode" >
<html:optionsCollection property="aBean" value="code"
label="descr"/>
</html:select>
</html:form>
</body>
</html:html>
________________________________________________________
myBean Class:
public class myBean implements java.io.Serializable{
private Integer code;
private String descr;
public Integer getCode(){return code;}
public String getDescr(){return descr;}
public void setCode(Integer val){ code=val;}
public void setDescr(String val){ descr=val;} }
_________________________________________________________
Could anyone help me?
Any help will be greatly appreciated.
Thanks in advance
Marcello
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Array of Bean and optionsCollection (revisted)
Posted by Marcello Savino <Ma...@aldebra.com>.
Hi all, i've the following problem using the tag <html:optionsCollection
Let's say this is my code (actionForm, jsp, bean class)
public class MyForm extends ActionForm {
private myBean[] arrayOfMyBean;
public void reset(ActionMapping mapping, HttpServletRequest
request){
arrayOfMyBean=someClass.getMyBeanArray();
request.setAttribute("aBean", arrayOfMyBean);
super.reset( mapping, request);
}
public myBean[] getABean(return arrayOfMyBean); // i forgot this
on my previous post, not on my code!
}
______________________________________________________
The jsp:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:xhtml />
<html:html locale="true">
<body>
<html:form action="/MyAction">
<html:select property="myBeanCode" >
<html:optionsCollection property="aBean" value="code"
label="descr"/>
</html:select>
</html:form>
</body>
</html:html>
________________________________________________________
myBean Class:
public class myBean implements java.io.Serializable{
private Integer code;
private String descr;
public Integer getCode(){return code;}
public String getDescr(){return descr;}
public void setCode(Integer val){ code=val;}
public void setDescr(String val){ descr=val;} }
_________________________________________________________
When i open the jsp i got the following Error:
org.apache.jasper.JasperException: No bean specified
Could anyone help me?
Any help will be greatly appreciated.
Thanks in advance
Marcello
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org