======================= 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" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Wednesday, June 11, 2003 9:54 AM Subject: Re: <html:text Error?...
theDo 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>user, but as the jsp is rendering that form, it needs to check the fieldsof>UserFormBean to display it's content (which could be null or empty inyourbe>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 toproperty="username"/>>the same..."UserFormBean"). > >Does this help? > > >-- >James Mitchell >Software Developer/Struts Evangelist >http://www.struts-atlanta.org > > >----- Original Message ----- >From: "Sloan Bowman" <[EMAIL PROTECTED]> >To: <[EMAIL PROTECTED]> >Sent: Wednesday, June 11, 2003 11:25 AM >Subject: <html:text Error?... > > > > When I am creating a form text field with <html:texthelp.> > 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> > > > > > --Sloan > > > > > > --------------------------------------------------------------------- > > 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]
--------------------------------------------------------------------- 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] * 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

