You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sloan Bowman <sm...@nashlinux.com> on 2003/06/11 17:25:38 UTC

When I am creating a form text field with <html:text property="username"/> 
I get the following error message. I wasn't aware I was supossed to be 
using a bean yet. I thought you put the bean in the submitted Action.


Cannot find bean org.apache.struts.taglib.html.BEAN in any scope

I am developing on Tomcat 4.1.18 and Struts 1.1.rc1. Thanks for your help.


--Sloan 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Posted by Sloan Bowman <sm...@nashlinux.com>.
I have been able to get one app working then when I tore it down and 
trying to start from stratch again to see if could finally figure it 
out I am getting the same error message. I am pasting the code below 
to see if you see anything I am doing wrong. Thanks for the help. I 
really appreciate it.


=======================
Logon Page Form
=======================
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<html>
   <head>
     <title>Logon</title>
   </head>
   <body>
   <html:form action="/LogonSubmit" focus="username"/>
   <table>
   <tr>
     <td>Username:</td>
     <td><html:text property="username"/></td>
   </tr>
   <tr>
     <td>Password:</td>
     <td><html:text property="password"/></td>
   </tr>
   <tr>
     <td></td>
     <td><html:submit/><html:reset/></td>
   </tr>
   </table>
   </html:form>
   </body>
</html>

=======================
LogonForm Bean
=======================
package app;

import org.apache.struts.action.*;

public class LogonForm extends ActionForm
{
     private String username;
     private String password;
     private String passwordMatch;

     public void setUsername(String aUsername)
     {
         this.username = aUsername;
     } // end setUsername()

     public String getUsername()
     {
         return(this.username);
     } // end getUsername()

     public void setPassword(String aPassword)
     {
         this.password = aPassword;
     } // end setPassword()

     public String getPassword()
     {
         return(this.password);
     } // end getPassword()

     public void setPasswordMatch(String aPassword)
     {
         this.passwordMatch = aPassword;
     } // end setPasswordMatch()

     public String getPasswordMatch()
     {
         return(this.passwordMatch);
     } // end getPasswordMatch

} // end class LogonForm


=======================
Struts config
=======================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>
     <!-- Configure the Form Beans -->
     <form-beans>
         <form-bean
             name="logonForm"
             type="app.LogonForm"/>
     </form-beans>

     <!-- Configure the Global Forwards -->
     <global-forwards>
         <forward name="welcome" path="/welcome.do"/>
         <forward name="logon" path="/logon.do"/>
     </global-forwards>

     <!-- Configure Action Mappings -->
     <action-mappings>
         <action
             parameter="/jsp/welcome.jsp"
             path="/welcome"
             type="org.apache.struts.actions.ForwardAction"/>
         <action
         <action
             path="/logon"
             type="org.apache.struts.actions.ForwardAction"
             parameter="/jsp/logon.jsp">
         </action>
         <action
             path="/LogonSubmit"
             type="app.LogonAction"
             name="logonForm"
             scope="request">
             <forward
                 name="success"
                 path="/jsp/myhome.jsp"/>
        </action>
     </action-mappings>
</struts-config>

Thanks again for the help..

Regards,
Sloan Bowman

>Take a look at the struts-example.  For subscriptions and registration
>tasks, there are 2 parts to the flow.
>
>1. Setup
>2. Save
>
>In a general sense "Setup" is usually an "edit" or a "new" when using the
>application.  The only difference being that edit uses some values from
>persistence to allow the user to edit them.  "new" just presents the user
>with a blank form so that they can fill it out from scratch.
>
>In both cases, the "setup" is handled by one action and uses a request
>parameter to determine if this is a a "new" subscription or "editing" an
>existing one.  That parameter is called (coincidentally) "action".
>
>Here's the struts-config entry to handle that:
>
>     <!-- Edit mail subscription -->
>     <action    path="/editSubscription"
>
>type="org.apache.struts.webapp.example.EditSubscriptionAction"
>           attribute="subscriptionForm"
>               scope="request"
>            validate="false">
>       <forward name="failure"              path="/mainMenu.jsp"/>
>       <forward name="success"              path="/subscription.jsp"/>
>     </action>
>
>
>..notice that this action uses attribute="subscriptionForm" instead of
>name="subscriptionForm" as is done when saving the subsciption...
>
>
>     <!-- Save mail subscription -->
>     <action    path="/saveSubscription"
>
>type="org.apache.struts.webapp.example.SaveSubscriptionAction"
>                name="subscriptionForm"
>               scope="request"
>               input="subscription">
>       <forward name="subscription"    path="/subscription.jsp"/>
>       <forward name="success"
>path="/editRegistration.do?action=Edit"/>
>     </action>
>
>
>What this essentially saying is..."let me setup the form on the way into the
>page, and let me tell struts which form I used when it gets submitted.
>
>I hope this clears it up for you.
>
>--
>James Mitchell
>Software Developer/Struts Evangelist
>http://www.struts-atlanta.org
>
>
>----- Original Message -----
>From: "Sloan Bowman" <sm...@nashlinux.com>
>To: "Struts Users Mailing List" <st...@jakarta.apache.org>
>Sent: Wednesday, June 11, 2003 9:54 AM
>Subject: Re: <html:text Error?...
>
>
>>  Do you mean specify the form bean in the struts-config.xml or the
>>  <html:form tag? Thanks for the help
>>
>>  --Sloan
>>
>>  At 11:25 AM 6/11/2003, you wrote:
>>  >You need to specify that your particular action uses a form-bean (for
>>  >example "UserFormBean").  You may be wanting to display a blank form to
>the
>>  >user, but as the jsp is rendering that form, it needs to check the fields
>of
>>  >UserFormBean to display it's content (which could be null or empty in
>your
>>  >case).  You would specify the action to submit to in the html:form tag.
>>  >Struts will then use the form-bean that you specified (which happens to
>be
>>  >the same..."UserFormBean").
>>  >
>>  >Does this help?
>>  >
>>  >
>>  >--
>>  >James Mitchell
>>  >Software Developer/Struts Evangelist
>>  >http://www.struts-atlanta.org
>>  >
>>  >
>>  >----- Original Message -----
>>  >From: "Sloan Bowman" <sm...@nashlinux.com>
>>  >To: <st...@jakarta.apache.org>
>>  >Sent: Wednesday, June 11, 2003 11:25 AM
>>  >Subject: <html:text Error?...
>>  >
>>  >
>>  > > When I am creating a form text field with <html:text
>property="username"/>
>>  > > I get the following error message. I wasn't aware I was supossed to be
>>  > > using a bean yet. I thought you put the bean in the submitted Action.
>>  > >
>>  > >
>>  > > Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
>>  > >
>>  > > I am developing on Tomcat 4.1.18 and Struts 1.1.rc1. Thanks for your
>help.
>>  > >
>>  > >
>>  > > --Sloan
>>  > >
>>  > >
>>  > > ---------------------------------------------------------------------
>>  > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>  > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>  >
>>  >
>>  >---------------------------------------------------------------------
>>  >To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>  >For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>  For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>* 153 FETCH (FLAGS (\Seen))


-- 
Sloan Bowman
www.nashlinux.com
www.q3networks.com
www.aboutgoodlettsville.com
www.spudibby.com
---------------------------
Windows 95/NT - 32 bit extensions and a graphical shell for a 16 bit 
patch to an 8 bit operating system originally coded for a 4 bit 
microprocessor, written by a 2 bit company that can't stand 1 bit of 
competition.

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Posted by James Mitchell <jm...@apache.org>.
Take a look at the struts-example.  For subscriptions and registration
tasks, there are 2 parts to the flow.

1. Setup
2. Save

In a general sense "Setup" is usually an "edit" or a "new" when using the
application.  The only difference being that edit uses some values from
persistence to allow the user to edit them.  "new" just presents the user
with a blank form so that they can fill it out from scratch.

In both cases, the "setup" is handled by one action and uses a request
parameter to determine if this is a a "new" subscription or "editing" an
existing one.  That parameter is called (coincidentally) "action".

Here's the struts-config entry to handle that:

    <!-- Edit mail subscription -->
    <action    path="/editSubscription"

type="org.apache.struts.webapp.example.EditSubscriptionAction"
          attribute="subscriptionForm"
              scope="request"
           validate="false">
      <forward name="failure"              path="/mainMenu.jsp"/>
      <forward name="success"              path="/subscription.jsp"/>
    </action>


...notice that this action uses attribute="subscriptionForm" instead of
name="subscriptionForm" as is done when saving the subsciption...


    <!-- Save mail subscription -->
    <action    path="/saveSubscription"

type="org.apache.struts.webapp.example.SaveSubscriptionAction"
               name="subscriptionForm"
              scope="request"
              input="subscription">
      <forward name="subscription"    path="/subscription.jsp"/>
      <forward name="success"
path="/editRegistration.do?action=Edit"/>
    </action>


What this essentially saying is..."let me setup the form on the way into the
page, and let me tell struts which form I used when it gets submitted.

I hope this clears it up for you.

--
James Mitchell
Software Developer/Struts Evangelist
http://www.struts-atlanta.org


----- Original Message ----- 
From: "Sloan Bowman" <sm...@nashlinux.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, June 11, 2003 9:54 AM
Subject: Re: <html:text Error?...


> Do you mean specify the form bean in the struts-config.xml or the
> <html:form tag? Thanks for the help
>
> --Sloan
>
> At 11:25 AM 6/11/2003, you wrote:
> >You need to specify that your particular action uses a form-bean (for
> >example "UserFormBean").  You may be wanting to display a blank form to
the
> >user, but as the jsp is rendering that form, it needs to check the fields
of
> >UserFormBean to display it's content (which could be null or empty in
your
> >case).  You would specify the action to submit to in the html:form tag.
> >Struts will then use the form-bean that you specified (which happens to
be
> >the same..."UserFormBean").
> >
> >Does this help?
> >
> >
> >--
> >James Mitchell
> >Software Developer/Struts Evangelist
> >http://www.struts-atlanta.org
> >
> >
> >----- Original Message -----
> >From: "Sloan Bowman" <sm...@nashlinux.com>
> >To: <st...@jakarta.apache.org>
> >Sent: Wednesday, June 11, 2003 11:25 AM
> >Subject: <html:text Error?...
> >
> >
> > > When I am creating a form text field with <html:text
property="username"/>
> > > I get the following error message. I wasn't aware I was supossed to be
> > > using a bean yet. I thought you put the bean in the submitted Action.
> > >
> > >
> > > Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
> > >
> > > I am developing on Tomcat 4.1.18 and Struts 1.1.rc1. Thanks for your
help.
> > >
> > >
> > > --Sloan
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Posted by Sloan Bowman <sm...@nashlinux.com>.
Do you mean specify the form bean in the struts-config.xml or the 
<html:form tag? Thanks for the help

--Sloan

At 11:25 AM 6/11/2003, you wrote:
>You need to specify that your particular action uses a form-bean (for
>example "UserFormBean").  You may be wanting to display a blank form to the
>user, but as the jsp is rendering that form, it needs to check the fields of
>UserFormBean to display it's content (which could be null or empty in your
>case).  You would specify the action to submit to in the html:form tag.
>Struts will then use the form-bean that you specified (which happens to be
>the same..."UserFormBean").
>
>Does this help?
>
>
>--
>James Mitchell
>Software Developer/Struts Evangelist
>http://www.struts-atlanta.org
>
>
>----- Original Message -----
>From: "Sloan Bowman" <sm...@nashlinux.com>
>To: <st...@jakarta.apache.org>
>Sent: Wednesday, June 11, 2003 11:25 AM
>Subject: <html:text Error?...
>
>
> > When I am creating a form text field with <html:text property="username"/>
> > I get the following error message. I wasn't aware I was supossed to be
> > using a bean yet. I thought you put the bean in the submitted Action.
> >
> >
> > Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
> >
> > I am developing on Tomcat 4.1.18 and Struts 1.1.rc1. Thanks for your help.
> >
> >
> > --Sloan
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Posted by James Mitchell <jm...@apache.org>.
You need to specify that your particular action uses a form-bean (for
example "UserFormBean").  You may be wanting to display a blank form to the
user, but as the jsp is rendering that form, it needs to check the fields of
UserFormBean to display it's content (which could be null or empty in your
case).  You would specify the action to submit to in the html:form tag.
Struts will then use the form-bean that you specified (which happens to be
the same..."UserFormBean").

Does this help?


--
James Mitchell
Software Developer/Struts Evangelist
http://www.struts-atlanta.org


----- Original Message -----
From: "Sloan Bowman" <sm...@nashlinux.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, June 11, 2003 11:25 AM
Subject: <html:text Error?...


> When I am creating a form text field with <html:text property="username"/>
> I get the following error message. I wasn't aware I was supossed to be
> using a bean yet. I thought you put the bean in the submitted Action.
>
>
> Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
>
> I am developing on Tomcat 4.1.18 and Struts 1.1.rc1. Thanks for your help.
>
>
> --Sloan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org