You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shannon Moschetti <sm...@wideforce.com> on 2001/06/05 18:34:50 UTC

Getting values from ActionForm bean

I'm new to struts and would like to get a handle on a few things.  I 
made certain to search the archives for an answer to my current problem, 
but was unable to find an answer.  So I post my question here.

I have an ActionForm in which I added a method that queries a database 
and gets a name/id pair and adds them to a hashtable.  On creation of 
the form(in the JSP associated with the ActionForm class) I want to 
populate a combobox on the form with values from the hashtable.  Here's 
what I tried, and the results of the code:

JSP
   <html:select property="customer" size="1">
       <html:options property="customers"/ labelName="value" 
labelProperty="key">
   </html:select>

ActionForm
public Hashtable getCustomers(){
   // query database, build hashtable
   return hash;
}

The ActionForm is a request scope bean, as specified in struts-config. 

Here's the error I get:
javax.servlet.jsp.JspException: Cannot find bean exportForm in scope request
   at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:486)
   at org.apache.struts.taglib.bean.DefineTag.doStartTag(DefineTag.java:200)
   at jsp_servlet._content._managerstart._jspService(_managerstart.java:297)
   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
   at 
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213)
   at 
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246)
   at 
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265)
   at 
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1622)
   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)


Re: Getting values from ActionForm bean

Posted by Eric Rasmussen <er...@websidestory.com>.
Is this a typo?  If not, it is probably your problem.

>>   <html:select property="customer" size="1">
>>       <html:options property="customers"/ labelName="value"
>> labelProperty="key">
>>   </html:select>

Should be:
<html:select property="customer" size="1">
  <html:options property="customers" labelName="value" labelProperty="key"/>
</html:select>

Backslash denoting end of element in wrong place.

Besides that, I use the 'collections' attribute of html:options, and don't
use labelName.  Example:
<html:select property="typeId">
  <html:options collection="typecollection" property="id"
labelProperty="name"/>
</html:select>

In this case, 'typecollection' is a Collection of objects that have getId()
and getName() methods.  The return of these methods will be used to populate
the drop-down list.  The 'property' attribute of the html:select element
denotes which option to select by default (that is, to add the 'selected'
attribute to).  This is determined by calling the method of the form bean
denoted by the 'property' attribute.  In other words, when the return of
[form_bean].getTypeId() matches [typecollection].getId(), the option would
be 'selected'.

Use case:  in the case that three objects in 'typecollection' had ids of
1,2,3 and names of name1,name2,name3, and the [form_bean].getTypeId()
returns 2, this would be the output:
<select name="typeId"><option value="1">name1</option>
<option value="2" selected>name2</option>
<option value="3">name3</option></select>

    Hope this helps,
        - eric

----- Original Message -----
From: "Shannon Moschetti" <sm...@wideforce.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, June 06, 2001 8:29 AM
Subject: Re: Getting values from ActionForm bean


> Boy, I thought for sure that someone would have a suggestion for me
> concerning this question.  Is more information needed?
>
> Shannon Moschetti wrote:
>
> > Sorry... the error generated from my JSP is as follows, and not the
> > error included in the original message:
> >
> > javax.servlet.jsp.JspException: No getter method available for
> > property customers for bean under name null
> >   at
> >
org.apache.struts.taglib.html.OptionsTag.getIterator(OptionsTag.java:338)
> >   at
> > org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:234)
> >   at
> > jsp_servlet._content._managerstart._jspService(_managerstart.java:337)
> >   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
> >   at
> >
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:213)
> >
> >   at
> >
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:246)
> >
> >   at
> >
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:1265)
> >
> >   at
> >
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:1622)
> >
> >   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
> >   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> >
> >
> > Shannon Moschetti wrote:
> >
> >> I'm new to struts and would like to get a handle on a few things.  I
> >> made certain to search the archives for an answer to my current
> >> problem, but was unable to find an answer.  So I post my question here.
> >>
> >> I have an ActionForm in which I added a method that queries a
> >> database and gets a name/id pair and adds them to a hashtable.  On
> >> creation of the form(in the JSP associated with the ActionForm class)
> >> I want to populate a combobox on the form with values from the
> >> hashtable.  Here's what I tried, and the results of the code:
> >>
> >> JSP
> >>   <html:select property="customer" size="1">
> >>       <html:options property="customers"/ labelName="value"
> >> labelProperty="key">
> >>   </html:select>
> >>
> >> ActionForm
> >> public Hashtable getCustomers(){
> >>   // query database, build hashtable
> >>   return hash;
> >> }
> >>
> >> The ActionForm is a request scope bean, as specified in struts-config.
> >> Here's the error I get:
> >> javax.servlet.jsp.JspException: Cannot find bean exportForm in scope
> >> request
> >>   at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:486)
> >>   at
> >> org.apache.struts.taglib.bean.DefineTag.doStartTag(DefineTag.java:200)
> >>   at
> >> jsp_servlet._content._managerstart._jspService(_managerstart.java:297)
> >>   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
> >>   at
> >>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:213)
> >>
> >>   at
> >>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:246)
> >>
> >>   at
> >>
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:1265)
> >>
> >>   at
> >>
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:1622)
> >>
> >>   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
> >>   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> >>
> >>
> >>
> >
> >
> >
>
>


Re: Getting values from ActionForm bean

Posted by Ted Husted <hu...@apache.org>.
My best advice would be to 

1) Link to an action first rather than directly to the JSP
2) Retrieve the options in the Action, and then put the hashtable into
the request
3) Forward the request to the JSP, and pickup from there

ActionForms are simply meant as a container for the input from an HTML
form. It's not a good idea to subclass them with other functionality.

If you post the question from that frame of reference, I'm sure you will
get a better response.

Shannon Moschetti wrote:
> 
> Included below is info from the jsp, form class, and config file.  Any
> advice?  I'm stuck.  I've got a fix, but its really
> terrible(embarrassing, but it works).
> 
> Here's the relevant JSP code(start.jsp):
> 
> <html:form action="/export">
>   <html:select property="customer" size="1">
>      <html:options property="customers" labelName="value"
> labelProperty="key"/>
>   </html:select>
>    <P>
>    <html:submit property="addButton" value="Export"/>
> </html:form>
> 
> ExportForm(ActionForm):
> public Hashtable getCustomers(){
>   ....
> 
>   Hashtable hash = new Hashtable();
>   ResultSet rset = statement.executeQuery("select name, id from table");
> 
>   while(rset.next()){
>        hash.put(rset.getString("name"), rset.getString("id"));
>   }
> 
>   .....
>   return hash;
> }
> 
> struts-config.xml:
> <form-beans>
>        <!-- Export Form  -->
>        <form-bean name="exportForm"
> type="com.foo.ui.struts.form.ExportForm"/>
> </form-beans>
> <global-forwards>
>        <forward name="export" path="/content/start.jsp"/>
> </global-forwards>
> <action-mappings>
>       <!-- Export Action -->
>       <action path="/export" input="/content/start.jsp"
> name="exportForm" scope="request"
> type="com.foo.ui.struts.action.ExportAction">
>            <forward name="manager" path="/content/start.jsp"/>
>        </action>
> </action-mappings>
> 
> John Raley wrote:
> 
> > (Sorry if this duplicates a previous response)
> >
> > The fact that the bean name is null makes me suspicious:
> > 1. Are you using <html:options> within an <html:form> tag?
> > 2. Does your action specify a name (in struts-config.xml)?
> > Or,
> > does your form bean class have a customers property?
> >
> > Shannon Moschetti wrote:
> >
> >> Boy, I thought for sure that someone would have a suggestion for me
> >> concerning this question.  Is more information needed?
> >>
> >> Shannon Moschetti wrote:
> >>
> >>> Sorry... the error generated from my JSP is as follows, and not the
> >>> error included in the original message:
> >>>
> >>> javax.servlet.jsp.JspException: No getter method available for
> >>> property customers for bean under name null
> >>>   at
> >>> org.apache.struts.taglib.html.OptionsTag.getIterator(OptionsTag.java:338)
> >>>
> >>>   at
> >>> org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:234)
> >>>   at
> >>> jsp_servlet._content._managerstart._jspService(_managerstart.java:337)
> >>>   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
> >>>   at
> >>> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213)
> >>>
> >>>   at
> >>> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246)
> >>>
> >>>   at
> >>> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265)
> >>>
> >>>   at
> >>> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1622)
> >>>
> >>>   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
> >>>   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> >>>
> >>>
> >>> Shannon Moschetti wrote:
> >>>
> >>>> I'm new to struts and would like to get a handle on a few things.
> >>>> I made certain to search the archives for an answer to my current
> >>>> problem, but was unable to find an answer.  So I post my question
> >>>> here.
> >>>>
> >>>> I have an ActionForm in which I added a method that queries a
> >>>> database and gets a name/id pair and adds them to a hashtable.  On
> >>>> creation of the form(in the JSP associated with the ActionForm
> >>>> class) I want to populate a combobox on the form with values from
> >>>> the hashtable.  Here's what I tried, and the results of the code:
> >>>>
> >>>> JSP
> >>>>   <html:select property="customer" size="1">
> >>>>       <html:options property="customers"/ labelName="value"
> >>>> labelProperty="key">
> >>>>   </html:select>
> >>>>
> >>>> ActionForm
> >>>> public Hashtable getCustomers(){
> >>>>   // query database, build hashtable
> >>>>   return hash;
> >>>> }
> >>>>
> >>>> The ActionForm is a request scope bean, as specified in struts-config.
> >>>> Here's the error I get:
> >>>> javax.servlet.jsp.JspException: Cannot find bean exportForm in
> >>>> scope request
> >>>>   at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:486)
> >>>>   at
> >>>> org.apache.struts.taglib.bean.DefineTag.doStartTag(DefineTag.java:200)
> >>>>   at
> >>>> jsp_servlet._content._managerstart._jspService(_managerstart.java:297)
> >>>>   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
> >>>>   at
> >>>> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213)
> >>>>
> >>>>   at
> >>>> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246)
> >>>>
> >>>>   at
> >>>> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265)
> >>>>
> >>>>   at
> >>>> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1622)
> >>>>
> >>>>   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
> >>>>   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>
> >>
> >
> >
> >
> >
> >

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/

Re: Getting values from ActionForm bean

Posted by Shannon Moschetti <sm...@wideforce.com>.
Included below is info from the jsp, form class, and config file.  Any 
advice?  I'm stuck.  I've got a fix, but its really 
terrible(embarrassing, but it works).

Here's the relevant JSP code(start.jsp):

<html:form action="/export">
  <html:select property="customer" size="1">
     <html:options property="customers" labelName="value"  
labelProperty="key"/>
  </html:select>
   <P>
   <html:submit property="addButton" value="Export"/>
</html:form>

ExportForm(ActionForm):
public Hashtable getCustomers(){
  ....

  Hashtable hash = new Hashtable();
  ResultSet rset = statement.executeQuery("select name, id from table");

  while(rset.next()){
       hash.put(rset.getString("name"), rset.getString("id"));
  }

  .....
  return hash;
}

struts-config.xml:
<form-beans>
       <!-- Export Form  -->
       <form-bean name="exportForm" 
type="com.foo.ui.struts.form.ExportForm"/>
</form-beans>
<global-forwards>
       <forward name="export" path="/content/start.jsp"/>
</global-forwards>
<action-mappings>
      <!-- Export Action -->
      <action path="/export" input="/content/start.jsp" 
name="exportForm" scope="request" 
type="com.foo.ui.struts.action.ExportAction">
           <forward name="manager" path="/content/start.jsp"/>
       </action>
</action-mappings>

John Raley wrote:

> (Sorry if this duplicates a previous response)
> 
> The fact that the bean name is null makes me suspicious:
> 1. Are you using <html:options> within an <html:form> tag?
> 2. Does your action specify a name (in struts-config.xml)?
> Or,
> does your form bean class have a customers property?
> 
> Shannon Moschetti wrote:
> 
>> Boy, I thought for sure that someone would have a suggestion for me 
>> concerning this question.  Is more information needed?
>> 
>> Shannon Moschetti wrote:
>> 
>>> Sorry... the error generated from my JSP is as follows, and not the 
>>> error included in the original message:
>>> 
>>> javax.servlet.jsp.JspException: No getter method available for 
>>> property customers for bean under name null
>>>   at 
>>> org.apache.struts.taglib.html.OptionsTag.getIterator(OptionsTag.java:338) 
>>> 
>>>   at 
>>> org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:234)
>>>   at 
>>> jsp_servlet._content._managerstart._jspService(_managerstart.java:337)
>>>   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>>>   at 
>>> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213) 
>>> 
>>>   at 
>>> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246) 
>>> 
>>>   at 
>>> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265) 
>>> 
>>>   at 
>>> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1622) 
>>> 
>>>   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>>>   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>>> 
>>> 
>>> Shannon Moschetti wrote:
>>> 
>>>> I'm new to struts and would like to get a handle on a few things.  
>>>> I made certain to search the archives for an answer to my current 
>>>> problem, but was unable to find an answer.  So I post my question 
>>>> here.
>>>> 
>>>> I have an ActionForm in which I added a method that queries a 
>>>> database and gets a name/id pair and adds them to a hashtable.  On 
>>>> creation of the form(in the JSP associated with the ActionForm 
>>>> class) I want to populate a combobox on the form with values from 
>>>> the hashtable.  Here's what I tried, and the results of the code:
>>>> 
>>>> JSP
>>>>   <html:select property="customer" size="1">
>>>>       <html:options property="customers"/ labelName="value" 
>>>> labelProperty="key">
>>>>   </html:select>
>>>> 
>>>> ActionForm
>>>> public Hashtable getCustomers(){
>>>>   // query database, build hashtable
>>>>   return hash;
>>>> }
>>>> 
>>>> The ActionForm is a request scope bean, as specified in struts-config.
>>>> Here's the error I get:
>>>> javax.servlet.jsp.JspException: Cannot find bean exportForm in 
>>>> scope request
>>>>   at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:486)
>>>>   at 
>>>> org.apache.struts.taglib.bean.DefineTag.doStartTag(DefineTag.java:200)
>>>>   at 
>>>> jsp_servlet._content._managerstart._jspService(_managerstart.java:297)
>>>>   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>>>>   at 
>>>> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213) 
>>>> 
>>>>   at 
>>>> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246) 
>>>> 
>>>>   at 
>>>> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265) 
>>>> 
>>>>   at 
>>>> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1622) 
>>>> 
>>>>   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>>>>   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>>>> 
>>>> 
>>>> 
>>> 
>>> 
>>> 
>> 
>> 
> 
> 
> 
> 
> 


Re: Getting values from ActionForm bean

Posted by John Raley <jo...@moonlight.com>.
(Sorry if this duplicates a previous response)

The fact that the bean name is null makes me suspicious:
1. Are you using <html:options> within an <html:form> tag?
2. Does your action specify a name (in struts-config.xml)?
Or,
does your form bean class have a customers property?

Shannon Moschetti wrote:

> Boy, I thought for sure that someone would have a suggestion for me 
> concerning this question.  Is more information needed?
>
> Shannon Moschetti wrote:
>
>> Sorry... the error generated from my JSP is as follows, and not the 
>> error included in the original message:
>>
>> javax.servlet.jsp.JspException: No getter method available for 
>> property customers for bean under name null
>>   at 
>> org.apache.struts.taglib.html.OptionsTag.getIterator(OptionsTag.java:338) 
>>
>>   at 
>> org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:234)
>>   at 
>> jsp_servlet._content._managerstart._jspService(_managerstart.java:337)
>>   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>>   at 
>> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213) 
>>
>>   at 
>> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246) 
>>
>>   at 
>> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265) 
>>
>>   at 
>> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1622) 
>>
>>   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>>   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>>
>>
>> Shannon Moschetti wrote:
>>
>>> I'm new to struts and would like to get a handle on a few things.  I 
>>> made certain to search the archives for an answer to my current 
>>> problem, but was unable to find an answer.  So I post my question here.
>>>
>>> I have an ActionForm in which I added a method that queries a 
>>> database and gets a name/id pair and adds them to a hashtable.  On 
>>> creation of the form(in the JSP associated with the ActionForm 
>>> class) I want to populate a combobox on the form with values from 
>>> the hashtable.  Here's what I tried, and the results of the code:
>>>
>>> JSP
>>>   <html:select property="customer" size="1">
>>>       <html:options property="customers"/ labelName="value" 
>>> labelProperty="key">
>>>   </html:select>
>>>
>>> ActionForm
>>> public Hashtable getCustomers(){
>>>   // query database, build hashtable
>>>   return hash;
>>> }
>>>
>>> The ActionForm is a request scope bean, as specified in struts-config.
>>> Here's the error I get:
>>> javax.servlet.jsp.JspException: Cannot find bean exportForm in scope 
>>> request
>>>   at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:486)
>>>   at 
>>> org.apache.struts.taglib.bean.DefineTag.doStartTag(DefineTag.java:200)
>>>   at 
>>> jsp_servlet._content._managerstart._jspService(_managerstart.java:297)
>>>   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>>>   at 
>>> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213) 
>>>
>>>   at 
>>> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246) 
>>>
>>>   at 
>>> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265) 
>>>
>>>   at 
>>> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1622) 
>>>
>>>   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>>>   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>>>
>>>
>>>
>>
>>
>>
>
>




Re: Getting values from ActionForm bean

Posted by Shannon Moschetti <sm...@wideforce.com>.
Boy, I thought for sure that someone would have a suggestion for me 
concerning this question.  Is more information needed?

Shannon Moschetti wrote:

> Sorry... the error generated from my JSP is as follows, and not the 
> error included in the original message:
> 
> javax.servlet.jsp.JspException: No getter method available for 
> property customers for bean under name null
>   at 
> org.apache.struts.taglib.html.OptionsTag.getIterator(OptionsTag.java:338)
>   at 
> org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:234)
>   at 
> jsp_servlet._content._managerstart._jspService(_managerstart.java:337)
>   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>   at 
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213) 
> 
>   at 
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246) 
> 
>   at 
> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265) 
> 
>   at 
> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1622) 
> 
>   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> 
> 
> Shannon Moschetti wrote:
> 
>> I'm new to struts and would like to get a handle on a few things.  I 
>> made certain to search the archives for an answer to my current 
>> problem, but was unable to find an answer.  So I post my question here.
>> 
>> I have an ActionForm in which I added a method that queries a 
>> database and gets a name/id pair and adds them to a hashtable.  On 
>> creation of the form(in the JSP associated with the ActionForm class) 
>> I want to populate a combobox on the form with values from the 
>> hashtable.  Here's what I tried, and the results of the code:
>> 
>> JSP
>>   <html:select property="customer" size="1">
>>       <html:options property="customers"/ labelName="value" 
>> labelProperty="key">
>>   </html:select>
>> 
>> ActionForm
>> public Hashtable getCustomers(){
>>   // query database, build hashtable
>>   return hash;
>> }
>> 
>> The ActionForm is a request scope bean, as specified in struts-config.
>> Here's the error I get:
>> javax.servlet.jsp.JspException: Cannot find bean exportForm in scope 
>> request
>>   at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:486)
>>   at 
>> org.apache.struts.taglib.bean.DefineTag.doStartTag(DefineTag.java:200)
>>   at 
>> jsp_servlet._content._managerstart._jspService(_managerstart.java:297)
>>   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>>   at 
>> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213) 
>> 
>>   at 
>> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246) 
>> 
>>   at 
>> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265) 
>> 
>>   at 
>> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1622) 
>> 
>>   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>>   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>> 
>> 
>> 
> 
> 
> 


Re: Getting values from ActionForm bean

Posted by Shannon Moschetti <sm...@wideforce.com>.
Sorry... the error generated from my JSP is as follows, and not the 
error included in the original message:

javax.servlet.jsp.JspException: No getter method available for property 
customers for bean under name null
   at 
org.apache.struts.taglib.html.OptionsTag.getIterator(OptionsTag.java:338)
   at org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:234)
   at jsp_servlet._content._managerstart._jspService(_managerstart.java:337)
   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
   at 
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213)
   at 
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246)
   at 
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265)
   at 
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1622)
   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)


Shannon Moschetti wrote:

> I'm new to struts and would like to get a handle on a few things.  I 
> made certain to search the archives for an answer to my current 
> problem, but was unable to find an answer.  So I post my question here.
> 
> I have an ActionForm in which I added a method that queries a database 
> and gets a name/id pair and adds them to a hashtable.  On creation of 
> the form(in the JSP associated with the ActionForm class) I want to 
> populate a combobox on the form with values from the hashtable.  
> Here's what I tried, and the results of the code:
> 
> JSP
>   <html:select property="customer" size="1">
>       <html:options property="customers"/ labelName="value" 
> labelProperty="key">
>   </html:select>
> 
> ActionForm
> public Hashtable getCustomers(){
>   // query database, build hashtable
>   return hash;
> }
> 
> The ActionForm is a request scope bean, as specified in struts-config.
> Here's the error I get:
> javax.servlet.jsp.JspException: Cannot find bean exportForm in scope 
> request
>   at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:486)
>   at 
> org.apache.struts.taglib.bean.DefineTag.doStartTag(DefineTag.java:200)
>   at 
> jsp_servlet._content._managerstart._jspService(_managerstart.java:297)
>   at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>   at 
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213) 
> 
>   at 
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246) 
> 
>   at 
> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265) 
> 
>   at 
> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1622) 
> 
>   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
> 
> 
>