You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Simon Raveh <Si...@nominum.com> on 2003/09/16 20:06:56 UTC

Problem with form submit

Hi I didn't get any response so I'm trying again.

I have a Change Password form with two buttons OK and Continue. The first
time the form render itself the OK button is enabled and the Continue button
is disabled. After the user submit the form and change the password, I
display the same page again with an info message added to it and switch the
state of the buttons,
the OK button is disabled and the Continue button is enabled.

How ever It seems that on the second time the page is being render the
Continue
button is not link to my listener, pressing on it does not invoke my
listener and I can see from the URL that I lost the session id.
After more Investigations I discover that the problem is the disabled
attribute in the second submit button ( the continue button ).
The moment I add the disabled attribute to the second submit button it stops
working.

The browser renders the buttons correctly but pressing on the button has no
effect.

Thanks Simon


here is my template page.

<body jwcid="@Body">
		<p>&nbsp;</p>
		<p>&nbsp;</p>
			<form jwcid="@Form"  delegate="ognl:beans.delegate">
				<table border="0" cellspacing="0" cellpadding="1" align="center"
class="tablestyle1">
					<tr>
						<td>
					<table width="282" border="0" cellspacing="0" cellpadding="0"
align="center">
						<tr>
							<td colspan="2" class="fontcontent6">
								<table width="100%" border="0" cellspacing="0" cellpadding="3">
									<tr>
										 <td class="maincolor4"><span class="fontcontent2"><b>Change
Password</b></span></td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td class="maincolor2" colspan="2" align="center">
								<table width="284" border="0" cellspacing="0" cellpadding="5">
									<tr>
										 <td colspan="2"><img src="images/global/spacer.gif" width="1"
height="1"></td>
									</tr>
									<!-- Begin -->
									<tr>
										<td colspan="2"><span class="message" jwcid="@Insert"
value="ognl:page.title">Some text here</span></td>
									</tr>
									<tr valign="bottom">
										<td colspan="2" height="15" align="center"><img
src="images/global/line_spacer1.gif" width="320" height="2"></td>
									 </tr>
									 <!-- end -->
									<tr>
										<td align="right"><span class="fieldlabel1"><span
jwcid="@FieldLabel" field="ognl:components.inputCurrentPassword" >Current
Password</span><span></td>
										<td align="right"><input jwcid="inputCurrentPassword" type="text"
name="currentPassword" class="formfield1"/></td>
									</tr>
									<tr>
										<td align="right"><span class="fieldlabel1"><span
jwcid="@FieldLabel"
field="ognl:components.inputNewPassword">Password</span></span></td>
										<td align="right"><input jwcid="inputNewPassword" type="text"
name="newPassword" class="formfield1"/></td>
									</tr>
									<tr>
										<td align="right"><span class="fieldlabel1"><span
jwcid="@FieldLabel" field="ognl:components.inputVerifyPassword"
class="fieldlabel1">Password</span></span></td>
										<td align="right"><input jwcid="inputVerifyPassword" type="text"
name="verifyPassword" class="formfield1"/></td>
									</tr>
									<tr>
										<td colspan="2" class="fontcontent3"><img
src="images/global/spacer.gif" width="1" height="1"></td>
									</tr>
									<tr valign="bottom">
										<td colspan="2" height="15" align="center"><img
src="images/global/line_spacer1.gif" width="320" height="2"></td>
									 </tr>
									 <tr>
										<td colspan="2">
											<span jwcid="@ShowError"/>
										</td>
									</tr>
									<tr>
										<td colspan="2">
											<span jwcid="@ShowMessage"/>
										</td>
									</tr>
									 <tr>
										<td colspan="2" align="right" height="40">
											<input type="submit" jwcid="@Submit"
listener="ognl:listeners.changePassword"   disabled="ognl:passwordChanged"
class="button1" value="OK" />
											&nbsp;&nbsp;
											<input type="submit" jwcid="@Submit"
listener="ognl:listeners.continueAction"  disabled="ognl:!passwordChanged"
class="button1" value="Continue" />
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				  </td>
				</tr>
			 </table>
		</form>
	</body>



and here is my java class

public abstract class ChangePassword extends ProtectedPage implements
IMessageProperty
{
	private String m_title ;

    public abstract void setCallback(ICallback value);
    public abstract ICallback getCallback();
    public abstract String getCurrentPassword();
    public abstract void setCurrentPassword(String password);
	public abstract String getNewPassword();
	public abstract void setNewPassword(String value);
	public abstract String getVerifyPassword();
	public abstract void setVerifyPassword(String value);


	public void setTitle( String title )
	{
		m_title = title ;
	}

	public String getTitle()
	{
		Visit v = (Visit)getVisit() ;
		UserToken tok = v.getToken() ;
		if( tok.isChangePassword() == UserToken.PASSWORD_CHANGE_REQ_FIRST_LOGIN )
			m_title =  v.getLocalizer().msg( "PASSWORD_CHANGE_REQ_FIRST_LOGIN") ;
		else if( tok.isChangePassword() == UserToken.PASSWORD_CHANGE_REQ_EXPIRE )
			m_title =  v.getLocalizer().msg( "PASSWORD_EXPIRED_MESSAGE" ) ;
		else
			m_title = v.getLocalizer().msg( "CHANGE_PASSWORD" ) ;

		return m_title ;
	}

	public void changePassword( IRequestCycle cycle )
	{
		String oldpassword =  getCurrentPassword() ;
		String newpassword = getNewPassword() ;
		String verfiyPassword = getVerifyPassword() ;

		IValidationDelegate delegate = getValidationDelegate();

		if (delegate.getHasErrors())
			return;

		Visit visit = (Visit)getVisit() ;
		FMCEngine fmcEngine = (FMCEngine) getEngine();

		if( !newpassword.equals( verfiyPassword ) )
		{
			fmcEngine.presentError( visit.getLocalizer().msg(
"PASSWORD_MATCH_ERROR_MESSAGE" ), 							cycle );
			return ;
		}

		Users user = new Users() ;
		try
		{
			user.changePassword( visit.getToken(), oldpassword, newpassword );
			visit.getToken().setChangePassword( UserToken.NO_PASSWORD_CHANGE_REQ );
			if( visit.getUser() != null )
				return ;

			long userId = ((Long)visit.getToken().getParamater(
UserToken.USER_ID )).longValue() ;
			UserDTO dto = user.getUser( userId, visit.getToken() ) ;
			visit.setUser( dto );

			/*InfoPage page = (InfoPage)cycle.getPage( "InfoPage" ) ;
			page.setMessage( visit.getLocalizer().msg( "PASSWORD_CHANGE_SUCCESS" ) );
			page.setCallback( getCallback() );*/

			IMessageProperty page = (IMessageProperty) cycle.getPage( cycle.getPage
().getPageName() );
			page.setMessage( visit.getLocalizer().msg( "PASSWORD_CHANGE_SUCCESS" ) );
			cycle.activate( page );
		}
		catch( WillowException e )
		{
			fmcEngine.handleWillowException( e, cycle );
		}
		catch( RemoteException e )
		{
			fmcEngine.rmiFailure( visit.getLocalizer().msg( "PASSWORD_CHANGE_FAIL" ),
e, 0 );
		}

	}

	public void continueAction( IRequestCycle cycle )
	{
		FMCEngine engine = (FMCEngine)cycle.getEngine();
		ICallback callback = getCallback();
		if( callback == null )
			cycle.activate( "Home" );
		else
			callback.performCallback(cycle);

		engine.forgetPage( getPageName() );
	}

}





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


RE: Problem with form submit

Posted by Simon Raveh <Si...@nominum.com>.
Cool !!!

Thanks for your time and help

Simon

-----Original Message-----
From: Bryan Lewis [mailto:bryan@maine.rr.com]
Sent: Tuesday, September 16, 2003 5:54 PM
To: Tapestry users
Subject: Re: Problem with form submit


Sonofagun.  I think you found something odd, probably in the interface
between
Tapestry and OGNL.

I started with this in the .page file, pretty much the same as yours except
moving the binding out of the html:

    <property-specification name="passwordChanged"  type="boolean"/>

    <component id="continueSubmit" type="Submit">
        <binding name="listener" expression="listeners.continueAction"/>
        <binding name="disabled" expression="!passwordChanged"/>
    </component>

I got the same behavior you did.  The Continue button appeared to be enabled
but clicking it did nothing.  As I suspected, passwordChanged wasn't being
remembered from one request to the next.  It was uninitialized (false) on
the
second request.  Adding:

    persistent="yes"

to the property-specification line fixed it.

The oddity is, why did the Continue button appear to be enabled?  If it had
stayed grayed out, the problem would've been more obvious.  I'll leave that
question to the ognl experts.  An uninitialized boolean 'disabled'
expression
caused a Submit button to be enabled (in the html view) but also disabled
(in
the sense that it had no listener).


----- Original Message -----
From: "Simon Raveh" <Si...@nominum.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Tuesday, September 16, 2003 7:00 PM
Subject: RE: Problem with form submit


> Here is the the simplefied version of the code for the change password.
>
>
> public abstract class ChangePassword
> {
>     public abstract void setCallback(ICallback value);
>     public abstract ICallback getCallback();
>     public abstract String getCurrentPassword();
>     public abstract void setCurrentPassword(String password);
>     public abstract String getNewPassword();
>     public abstract void setNewPassword(String value);
>     public abstract String getVerifyPassword();
>     public abstract void setVerifyPassword(String value);
>     public abstract void setPasswordChanged( boolean b );
>     public abstract boolean isPasswordChanged() ;
>
> public void changePassword( IRequestCycle cycle )
> {
> String oldpassword =  getCurrentPassword() ;
> String newpassword = getNewPassword() ;
> String verfiyPassword = getVerifyPassword() ;
>
> IValidationDelegate delegate = getValidationDelegate();
>
> if (delegate.getHasErrors())
> return;
>
> Visit visit = (Visit)getVisit() ;
>
> try
> {
> //The code to change the password goes here
> setPasswordChanged( true );
> cycle.activate( page );
> }
> catch( WillowException e )
> {
> fmcEngine.handleWillowException( e, cycle );
> }
> catch( RemoteException e )
> {
> fmcEngine.rmiFailure( visit.getLocalizer().msg( "PASSWORD_CHANGE_FAIL" ),
> e, 0 );
> }
>
> }
>
> public void continueAction( IRequestCycle cycle )
> {
> ICallback callback = getCallback();
> if( callback == null )
> cycle.activate( "Home" );
> else
> callback.performCallback(cycle);
>
> engine.forgetPage( getPageName() );
> }
> }
>
>
> the ChangePassword.page file
>
> <page-specification
> class="com.nominum.management.web.presentation.pages.ChangePassword">
>
> <property-specification name="error"            type="java.lang.String"/>
> <property-specification name="title"            type="java.lang.String"/>
> <property-specification name="currentPassword"  type="java.lang.String"/>
>   <property-specification name="newPassword"
type="java.lang.String"/>
>   <property-specification name="verifyPassword"
type="java.lang.String"/>
> <property-specification name="passwordChanged"  type="boolean"/>
> <property-specification name="message"          type="java.lang.String"/>
>   <property-specification name="callback"
> type="org.apache.tapestry.callback.ICallback" persistent="yes"/>
>
>   <bean name="delegate" class="com.nominum.management.web.FMCDeligate"/>
>
>   <bean name="validator" class="org.apache.tapestry.valid.StringValidator"
> lifecycle="page">
>   <set-property name="required" expression="true"/>
>   <set-property name="clientScriptingEnabled" expression="true"/>
>   </bean>
>
> <component id="inputCurrentPassword" type="ValidField">
>     <binding name="value" expression="currentPassword"/>
>     <binding name="validator" expression="beans.validator"/>
>     <static-binding name="displayName" value="Current Password"/>
>     <binding name="hidden" expression="true"/>
>   </component>
>
>   <component id="inputNewPassword" type="ValidField">
>     <binding name="value" expression="newPassword"/>
>     <binding name="validator" expression="beans.validator"/>
>     <static-binding name="displayName" value="New Password"/>
>     <binding name="hidden" expression="true"/>
>   </component>
>
> <component id="inputVerifyPassword" type="ValidField">
>     <binding name="value" expression="verifyPassword"/>
>     <binding name="validator" expression="beans.validator"/>
>     <static-binding name="displayName" value="Verify Password"/>
>     <binding name="hidden" expression="true"/>
>   </component>
>
> </page-specification>
>
>
> the HTML file
>
> <html>
> <head>
> <title>Nominum Foundation Management Center</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> <meta http-equiv="Cache-Control" Content="no-cache">
> <meta http-equiv="Pragma" Content="no-cache">
> <meta http-equiv="Expires" Content="0">
> </head>
> <body jwcid="@Body">
> <p>&nbsp;</p>
> <p>&nbsp;</p>
> <form jwcid="@Form"  delegate="ognl:beans.delegate">
> <table border="0" cellspacing="0" cellpadding="1" align="center">
> <tr>
> <td>
> <table width="282" border="0" cellspacing="0" cellpadding="0"
> align="center">
> <tr>
> <td colspan="2" >
> <table width="100%" border="0" cellspacing="0" cellpadding="3">
> <tr>
> <td><b>Change Password</b></td>
> </tr>
> </table>
> </td>
> </tr>
> <tr>
> <td colspan="2" align="center">
> <table width="284" border="0" cellspacing="0" cellpadding="5">
> <tr>
> <td align="right"><span jwcid="@FieldLabel"
> field="ognl:components.inputCurrentPassword" >Current Password</span></td>
> <td align="right"><input jwcid="inputCurrentPassword" type="text"
> name="currentPassword" /></td>
> </tr>
> <tr>
> <td align="right"><span jwcid="@FieldLabel"
> field="ognl:components.inputNewPassword">Password</span></td>
> <td align="right"><input jwcid="inputNewPassword" type="text"
> name="newPassword" /></td>
> </tr>
> <tr>
> <td align="right"><span jwcid="@FieldLabel"
> field="ognl:components.inputVerifyPassword">Password</span></td>
> <td align="right"><input jwcid="inputVerifyPassword" type="text"
> name="verifyPassword" /></td>
> </tr>
> <tr>
> <td colspan="2">
> <span jwcid="@ShowError"/>
> </td>
> </tr>
> <tr>
> <td colspan="2">
> <span jwcid="@ShowMessage"/>
> </td>
> </tr>
> <tr>
> <td colspan="2" align="right" height="40">
> <input type="submit" jwcid="@Submit"
> listener="ognl:listeners.changePassword"   disabled="ognl:passwordChanged"
> value="OK" />
> &nbsp;&nbsp;
> <input type="submit" jwcid="@Submit"
> listener="ognl:listeners.continueAction"
disabled="ognl:!passwordChanged"
> value="Continue" />
> </td>
> </tr>
> </table>
> </td>
> </tr>
> </table>
> </td>
> </tr>
> </table>
> </form>
> </body>
> </html>
>
>
>
>
>
>
> -----Original Message-----
> From: Bryan Lewis [mailto:bryan@maine.rr.com]
> Sent: Tuesday, September 16, 2003 3:12 PM
> To: Tapestry users
> Subject: Re: Problem with form submit
>
>
> Simon Raveh wrote:
> > This line of code is inside the continueAction method which is the
> listener
> > for the second submit button. This method should be invoke when the user
> > press on the continue button but I never got to this point because after
> > pressing on the OK button the continue button stop working and this
method
> > is never called.
>
> I took a quick debugging pass on this, but I had to simplify it greatly.
> There
> were a couple of syntax errors:
>
> Unclosed <span> tag in:
>
>     <td align="right"><span class="fieldlabel1"><span
>     jwcid="@FieldLabel" field="ognl:components.inputCurrentPassword"
> >Current
>     Password</span><span></td>
>
> And a typo in:
>
>     if( !newpassword.equals( verfiyPassword ) )
>
> But the main thing is, I don't see the passwordChanged methods in the
code.
> I
> suspect it's a property defined in the .page file, but that file wasn't
> posted.
> Even if there is such a property, I don't see any call to
> setPasswordChanged().
>
> It would help if you posted a pared-down example without the custom
images,
> css
> classes, base class, and localization.
>
> I pared it way down and didn't see any problem.  The Continue button
invoked
> its listener as expected.  I could send you my files if it would help but
> they're nothing special.  I added to the code:
>
>     private boolean passwordChanged;
>     public boolean getPasswordChanged() { return passwordChanged; }
>     public void setPasswordChanged(boolean value) { passwordChanged =
> value; }
>
>     public void changePassword( IRequestCycle cycle )
>     {
>         System.out.println("Password changing would happen here");
>         setPasswordChanged(true);
>     }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


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


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


Re: Problem with form submit

Posted by Bryan Lewis <br...@maine.rr.com>.
Sonofagun.  I think you found something odd, probably in the interface between
Tapestry and OGNL.

I started with this in the .page file, pretty much the same as yours except
moving the binding out of the html:

    <property-specification name="passwordChanged"  type="boolean"/>

    <component id="continueSubmit" type="Submit">
        <binding name="listener" expression="listeners.continueAction"/>
        <binding name="disabled" expression="!passwordChanged"/>
    </component>

I got the same behavior you did.  The Continue button appeared to be enabled
but clicking it did nothing.  As I suspected, passwordChanged wasn't being
remembered from one request to the next.  It was uninitialized (false) on the
second request.  Adding:

    persistent="yes"

to the property-specification line fixed it.

The oddity is, why did the Continue button appear to be enabled?  If it had
stayed grayed out, the problem would've been more obvious.  I'll leave that
question to the ognl experts.  An uninitialized boolean 'disabled' expression
caused a Submit button to be enabled (in the html view) but also disabled (in
the sense that it had no listener).


----- Original Message ----- 
From: "Simon Raveh" <Si...@nominum.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Tuesday, September 16, 2003 7:00 PM
Subject: RE: Problem with form submit


> Here is the the simplefied version of the code for the change password.
>
>
> public abstract class ChangePassword
> {
>     public abstract void setCallback(ICallback value);
>     public abstract ICallback getCallback();
>     public abstract String getCurrentPassword();
>     public abstract void setCurrentPassword(String password);
>     public abstract String getNewPassword();
>     public abstract void setNewPassword(String value);
>     public abstract String getVerifyPassword();
>     public abstract void setVerifyPassword(String value);
>     public abstract void setPasswordChanged( boolean b );
>     public abstract boolean isPasswordChanged() ;
>
> public void changePassword( IRequestCycle cycle )
> {
> String oldpassword =  getCurrentPassword() ;
> String newpassword = getNewPassword() ;
> String verfiyPassword = getVerifyPassword() ;
>
> IValidationDelegate delegate = getValidationDelegate();
>
> if (delegate.getHasErrors())
> return;
>
> Visit visit = (Visit)getVisit() ;
>
> try
> {
> //The code to change the password goes here
> setPasswordChanged( true );
> cycle.activate( page );
> }
> catch( WillowException e )
> {
> fmcEngine.handleWillowException( e, cycle );
> }
> catch( RemoteException e )
> {
> fmcEngine.rmiFailure( visit.getLocalizer().msg( "PASSWORD_CHANGE_FAIL" ),
> e, 0 );
> }
>
> }
>
> public void continueAction( IRequestCycle cycle )
> {
> ICallback callback = getCallback();
> if( callback == null )
> cycle.activate( "Home" );
> else
> callback.performCallback(cycle);
>
> engine.forgetPage( getPageName() );
> }
> }
>
>
> the ChangePassword.page file
>
> <page-specification
> class="com.nominum.management.web.presentation.pages.ChangePassword">
>
> <property-specification name="error"            type="java.lang.String"/>
> <property-specification name="title"            type="java.lang.String"/>
> <property-specification name="currentPassword"  type="java.lang.String"/>
>   <property-specification name="newPassword"      type="java.lang.String"/>
>   <property-specification name="verifyPassword"   type="java.lang.String"/>
> <property-specification name="passwordChanged"  type="boolean"/>
> <property-specification name="message"          type="java.lang.String"/>
>   <property-specification name="callback"
> type="org.apache.tapestry.callback.ICallback" persistent="yes"/>
>
>   <bean name="delegate" class="com.nominum.management.web.FMCDeligate"/>
>
>   <bean name="validator" class="org.apache.tapestry.valid.StringValidator"
> lifecycle="page">
>   <set-property name="required" expression="true"/>
>   <set-property name="clientScriptingEnabled" expression="true"/>
>   </bean>
>
> <component id="inputCurrentPassword" type="ValidField">
>     <binding name="value" expression="currentPassword"/>
>     <binding name="validator" expression="beans.validator"/>
>     <static-binding name="displayName" value="Current Password"/>
>     <binding name="hidden" expression="true"/>
>   </component>
>
>   <component id="inputNewPassword" type="ValidField">
>     <binding name="value" expression="newPassword"/>
>     <binding name="validator" expression="beans.validator"/>
>     <static-binding name="displayName" value="New Password"/>
>     <binding name="hidden" expression="true"/>
>   </component>
>
> <component id="inputVerifyPassword" type="ValidField">
>     <binding name="value" expression="verifyPassword"/>
>     <binding name="validator" expression="beans.validator"/>
>     <static-binding name="displayName" value="Verify Password"/>
>     <binding name="hidden" expression="true"/>
>   </component>
>
> </page-specification>
>
>
> the HTML file
>
> <html>
> <head>
> <title>Nominum Foundation Management Center</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> <meta http-equiv="Cache-Control" Content="no-cache">
> <meta http-equiv="Pragma" Content="no-cache">
> <meta http-equiv="Expires" Content="0">
> </head>
> <body jwcid="@Body">
> <p>&nbsp;</p>
> <p>&nbsp;</p>
> <form jwcid="@Form"  delegate="ognl:beans.delegate">
> <table border="0" cellspacing="0" cellpadding="1" align="center">
> <tr>
> <td>
> <table width="282" border="0" cellspacing="0" cellpadding="0"
> align="center">
> <tr>
> <td colspan="2" >
> <table width="100%" border="0" cellspacing="0" cellpadding="3">
> <tr>
> <td><b>Change Password</b></td>
> </tr>
> </table>
> </td>
> </tr>
> <tr>
> <td colspan="2" align="center">
> <table width="284" border="0" cellspacing="0" cellpadding="5">
> <tr>
> <td align="right"><span jwcid="@FieldLabel"
> field="ognl:components.inputCurrentPassword" >Current Password</span></td>
> <td align="right"><input jwcid="inputCurrentPassword" type="text"
> name="currentPassword" /></td>
> </tr>
> <tr>
> <td align="right"><span jwcid="@FieldLabel"
> field="ognl:components.inputNewPassword">Password</span></td>
> <td align="right"><input jwcid="inputNewPassword" type="text"
> name="newPassword" /></td>
> </tr>
> <tr>
> <td align="right"><span jwcid="@FieldLabel"
> field="ognl:components.inputVerifyPassword">Password</span></td>
> <td align="right"><input jwcid="inputVerifyPassword" type="text"
> name="verifyPassword" /></td>
> </tr>
> <tr>
> <td colspan="2">
> <span jwcid="@ShowError"/>
> </td>
> </tr>
> <tr>
> <td colspan="2">
> <span jwcid="@ShowMessage"/>
> </td>
> </tr>
> <tr>
> <td colspan="2" align="right" height="40">
> <input type="submit" jwcid="@Submit"
> listener="ognl:listeners.changePassword"   disabled="ognl:passwordChanged"
> value="OK" />
> &nbsp;&nbsp;
> <input type="submit" jwcid="@Submit"
> listener="ognl:listeners.continueAction"   disabled="ognl:!passwordChanged"
> value="Continue" />
> </td>
> </tr>
> </table>
> </td>
> </tr>
> </table>
> </td>
> </tr>
> </table>
> </form>
> </body>
> </html>
>
>
>
>
>
>
> -----Original Message-----
> From: Bryan Lewis [mailto:bryan@maine.rr.com]
> Sent: Tuesday, September 16, 2003 3:12 PM
> To: Tapestry users
> Subject: Re: Problem with form submit
>
>
> Simon Raveh wrote:
> > This line of code is inside the continueAction method which is the
> listener
> > for the second submit button. This method should be invoke when the user
> > press on the continue button but I never got to this point because after
> > pressing on the OK button the continue button stop working and this method
> > is never called.
>
> I took a quick debugging pass on this, but I had to simplify it greatly.
> There
> were a couple of syntax errors:
>
> Unclosed <span> tag in:
>
>     <td align="right"><span class="fieldlabel1"><span
>     jwcid="@FieldLabel" field="ognl:components.inputCurrentPassword"
> >Current
>     Password</span><span></td>
>
> And a typo in:
>
>     if( !newpassword.equals( verfiyPassword ) )
>
> But the main thing is, I don't see the passwordChanged methods in the code.
> I
> suspect it's a property defined in the .page file, but that file wasn't
> posted.
> Even if there is such a property, I don't see any call to
> setPasswordChanged().
>
> It would help if you posted a pared-down example without the custom images,
> css
> classes, base class, and localization.
>
> I pared it way down and didn't see any problem.  The Continue button invoked
> its listener as expected.  I could send you my files if it would help but
> they're nothing special.  I added to the code:
>
>     private boolean passwordChanged;
>     public boolean getPasswordChanged() { return passwordChanged; }
>     public void setPasswordChanged(boolean value) { passwordChanged =
> value; }
>
>     public void changePassword( IRequestCycle cycle )
>     {
>         System.out.println("Password changing would happen here");
>         setPasswordChanged(true);
>     }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


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


RE: Problem with form submit

Posted by Simon Raveh <Si...@nominum.com>.
Here is the the simplefied version of the code for the change password.


public abstract class ChangePassword
{
    public abstract void setCallback(ICallback value);
    public abstract ICallback getCallback();
    public abstract String getCurrentPassword();
    public abstract void setCurrentPassword(String password);
    public abstract String getNewPassword();
    public abstract void setNewPassword(String value);
    public abstract String getVerifyPassword();
    public abstract void setVerifyPassword(String value);
    public abstract void setPasswordChanged( boolean b );
    public abstract boolean isPasswordChanged() ;

	public void changePassword( IRequestCycle cycle )
	{
		String oldpassword =  getCurrentPassword() ;
		String newpassword = getNewPassword() ;
		String verfiyPassword = getVerifyPassword() ;

		IValidationDelegate delegate = getValidationDelegate();

		if (delegate.getHasErrors())
			return;

		Visit visit = (Visit)getVisit() ;

		try
		{
			//The code to change the password goes here
			setPasswordChanged( true );
			cycle.activate( page );
		}
		catch( WillowException e )
		{
			fmcEngine.handleWillowException( e, cycle );
		}
		catch( RemoteException e )
		{
			fmcEngine.rmiFailure( visit.getLocalizer().msg( "PASSWORD_CHANGE_FAIL" ),
e, 0 );
		}

	}

	public void continueAction( IRequestCycle cycle )
	{
		ICallback callback = getCallback();
		if( callback == null )
			cycle.activate( "Home" );
		else
			callback.performCallback(cycle);

		engine.forgetPage( getPageName() );
	}
}


the ChangePassword.page file

<page-specification
class="com.nominum.management.web.presentation.pages.ChangePassword">

	<property-specification name="error"            type="java.lang.String"/>
	<property-specification name="title"            type="java.lang.String"/>
	<property-specification name="currentPassword"  type="java.lang.String"/>
  	<property-specification name="newPassword"      type="java.lang.String"/>
  	<property-specification name="verifyPassword"   type="java.lang.String"/>
	<property-specification name="passwordChanged"  type="boolean"/>
	<property-specification name="message"          type="java.lang.String"/>
  	<property-specification name="callback"
type="org.apache.tapestry.callback.ICallback" persistent="yes"/>

  	<bean name="delegate" class="com.nominum.management.web.FMCDeligate"/>

  	<bean name="validator" class="org.apache.tapestry.valid.StringValidator"
lifecycle="page">
  		<set-property name="required" expression="true"/>
  		<set-property name="clientScriptingEnabled" expression="true"/>
  	</bean>

	<component id="inputCurrentPassword" type="ValidField">
    	<binding name="value" expression="currentPassword"/>
    	<binding name="validator" expression="beans.validator"/>
    	<static-binding name="displayName" value="Current Password"/>
    	<binding name="hidden" expression="true"/>
  	</component>

  	<component id="inputNewPassword" type="ValidField">
    	<binding name="value" expression="newPassword"/>
    	<binding name="validator" expression="beans.validator"/>
    	<static-binding name="displayName" value="New Password"/>
    	<binding name="hidden" expression="true"/>
  	</component>

	<component id="inputVerifyPassword" type="ValidField">
    	<binding name="value" expression="verifyPassword"/>
    	<binding name="validator" expression="beans.validator"/>
    	<static-binding name="displayName" value="Verify Password"/>
    	<binding name="hidden" expression="true"/>
  	</component>

</page-specification>


the HTML file

<html>
<head>
<title>Nominum Foundation Management Center</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Cache-Control" Content="no-cache">
<meta http-equiv="Pragma" Content="no-cache">
<meta http-equiv="Expires" Content="0">
</head>
<body jwcid="@Body">
<p>&nbsp;</p>
<p>&nbsp;</p>
<form jwcid="@Form"  delegate="ognl:beans.delegate">
<table border="0" cellspacing="0" cellpadding="1" align="center">
<tr>
<td>
<table width="282" border="0" cellspacing="0" cellpadding="0"
align="center">
<tr>
<td colspan="2" >
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td><b>Change Password</b></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<table width="284" border="0" cellspacing="0" cellpadding="5">
<tr>
<td align="right"><span jwcid="@FieldLabel"
field="ognl:components.inputCurrentPassword" >Current Password</span></td>
<td align="right"><input jwcid="inputCurrentPassword" type="text"
name="currentPassword" /></td>
</tr>
<tr>
<td align="right"><span jwcid="@FieldLabel"
field="ognl:components.inputNewPassword">Password</span></td>
<td align="right"><input jwcid="inputNewPassword" type="text"
name="newPassword" /></td>
</tr>
<tr>
<td align="right"><span jwcid="@FieldLabel"
field="ognl:components.inputVerifyPassword">Password</span></td>
<td align="right"><input jwcid="inputVerifyPassword" type="text"
name="verifyPassword" /></td>
</tr>
<tr>
<td colspan="2">
<span jwcid="@ShowError"/>
</td>
</tr>
<tr>
<td colspan="2">
<span jwcid="@ShowMessage"/>
</td>
</tr>
<tr>
<td colspan="2" align="right" height="40">
<input type="submit" jwcid="@Submit"
listener="ognl:listeners.changePassword"   disabled="ognl:passwordChanged"
value="OK" />
&nbsp;&nbsp;
<input type="submit" jwcid="@Submit"
listener="ognl:listeners.continueAction"   disabled="ognl:!passwordChanged"
value="Continue" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>






-----Original Message-----
From: Bryan Lewis [mailto:bryan@maine.rr.com]
Sent: Tuesday, September 16, 2003 3:12 PM
To: Tapestry users
Subject: Re: Problem with form submit


Simon Raveh wrote:
> This line of code is inside the continueAction method which is the
listener
> for the second submit button. This method should be invoke when the user
> press on the continue button but I never got to this point because after
> pressing on the OK button the continue button stop working and this method
> is never called.

I took a quick debugging pass on this, but I had to simplify it greatly.
There
were a couple of syntax errors:

Unclosed <span> tag in:

    <td align="right"><span class="fieldlabel1"><span
    jwcid="@FieldLabel" field="ognl:components.inputCurrentPassword"
>Current
    Password</span><span></td>

And a typo in:

    if( !newpassword.equals( verfiyPassword ) )

But the main thing is, I don't see the passwordChanged methods in the code.
I
suspect it's a property defined in the .page file, but that file wasn't
posted.
Even if there is such a property, I don't see any call to
setPasswordChanged().

It would help if you posted a pared-down example without the custom images,
css
classes, base class, and localization.

I pared it way down and didn't see any problem.  The Continue button invoked
its listener as expected.  I could send you my files if it would help but
they're nothing special.  I added to the code:

    private boolean passwordChanged;
    public boolean getPasswordChanged() { return passwordChanged; }
    public void setPasswordChanged(boolean value) { passwordChanged =
value; }

    public void changePassword( IRequestCycle cycle )
    {
        System.out.println("Password changing would happen here");
        setPasswordChanged(true);
    }


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


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


RE: Problem with form submit

Posted by Simon Raveh <Si...@nominum.com>.
Thanks very much for the help.
I have to apologize, between my first post regarding this problem and today
I did some changes to the code to workaround this problem. This is why you
didn't see the call to passwordChanged.
I'll reformat the code as you suggested and repost it again.

Thanks again for your time and help.

Simon



-----Original Message-----
From: Bryan Lewis [mailto:bryan@maine.rr.com]
Sent: Tuesday, September 16, 2003 3:12 PM
To: Tapestry users
Subject: Re: Problem with form submit


Simon Raveh wrote:
> This line of code is inside the continueAction method which is the
listener
> for the second submit button. This method should be invoke when the user
> press on the continue button but I never got to this point because after
> pressing on the OK button the continue button stop working and this method
> is never called.

I took a quick debugging pass on this, but I had to simplify it greatly.
There
were a couple of syntax errors:

Unclosed <span> tag in:

    <td align="right"><span class="fieldlabel1"><span
    jwcid="@FieldLabel" field="ognl:components.inputCurrentPassword"
>Current
    Password</span><span></td>

And a typo in:

    if( !newpassword.equals( verfiyPassword ) )

But the main thing is, I don't see the passwordChanged methods in the code.
I
suspect it's a property defined in the .page file, but that file wasn't
posted.
Even if there is such a property, I don't see any call to
setPasswordChanged().

It would help if you posted a pared-down example without the custom images,
css
classes, base class, and localization.

I pared it way down and didn't see any problem.  The Continue button invoked
its listener as expected.  I could send you my files if it would help but
they're nothing special.  I added to the code:

    private boolean passwordChanged;
    public boolean getPasswordChanged() { return passwordChanged; }
    public void setPasswordChanged(boolean value) { passwordChanged =
value; }

    public void changePassword( IRequestCycle cycle )
    {
        System.out.println("Password changing would happen here");
        setPasswordChanged(true);
    }


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


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


Re: Problem with form submit

Posted by Bryan Lewis <br...@maine.rr.com>.
Simon Raveh wrote:
> This line of code is inside the continueAction method which is the listener
> for the second submit button. This method should be invoke when the user
> press on the continue button but I never got to this point because after
> pressing on the OK button the continue button stop working and this method
> is never called.

I took a quick debugging pass on this, but I had to simplify it greatly.  There
were a couple of syntax errors:

Unclosed <span> tag in:

    <td align="right"><span class="fieldlabel1"><span
    jwcid="@FieldLabel" field="ognl:components.inputCurrentPassword" >Current
    Password</span><span></td>

And a typo in:

    if( !newpassword.equals( verfiyPassword ) )

But the main thing is, I don't see the passwordChanged methods in the code.  I
suspect it's a property defined in the .page file, but that file wasn't posted.
Even if there is such a property, I don't see any call to setPasswordChanged().

It would help if you posted a pared-down example without the custom images, css
classes, base class, and localization.

I pared it way down and didn't see any problem.  The Continue button invoked
its listener as expected.  I could send you my files if it would help but
they're nothing special.  I added to the code:

    private boolean passwordChanged;
    public boolean getPasswordChanged() { return passwordChanged; }
    public void setPasswordChanged(boolean value) { passwordChanged = value; }

    public void changePassword( IRequestCycle cycle )
    {
        System.out.println("Password changing would happen here");
        setPasswordChanged(true);
    }


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


RE: Problem with form submit

Posted by Simon Raveh <Si...@nominum.com>.
This line of code is inside the continueAction method which is the listener
for the second submit button. This method should be invoke when the user
press on the continue button but I never got to this point because after
pressing on the OK button the continue button stop working and this method
is never called.

Simon

-----Original Message-----
From: Bryan Lewis [mailto:bryan@maine.rr.com]
Sent: Tuesday, September 16, 2003 12:28 PM
To: Tapestry users
Subject: Re: Problem with form submit


This is only a guess after skimming the code... what's the purpose of that
statement

    engine.forgetPage( getPageName() );

?  Accoring to the API, "All property changes for the page are lost," which
might explain why it doesn't work as expected the second time around.  Does
the
page work with that line commented out?


----- Original Message -----
From: "Simon Raveh" <Si...@nominum.com>
To: "Tapestry-User" <ta...@jakarta.apache.org>
Sent: Tuesday, September 16, 2003 2:06 PM
Subject: Problem with form submit


> Hi I didn't get any response so I'm trying again.
>
> I have a Change Password form with two buttons OK and Continue. The first
> time the form render itself the OK button is enabled and the Continue
button
> is disabled. After the user submit the form and change the password, I
> display the same page again with an info message added to it and switch
the
> state of the buttons,
> the OK button is disabled and the Continue button is enabled.
>
> How ever It seems that on the second time the page is being render the
> Continue
> button is not link to my listener, pressing on it does not invoke my
> listener and I can see from the URL that I lost the session id.
> After more Investigations I discover that the problem is the disabled
> attribute in the second submit button ( the continue button ).
> The moment I add the disabled attribute to the second submit button it
stops
> working.
>
> The browser renders the buttons correctly but pressing on the button has
no
> effect.
>
> Thanks Simon
>
>
> here is my template page.
>
> <body jwcid="@Body">
> <p>&nbsp;</p>
> <p>&nbsp;</p>
> <form jwcid="@Form"  delegate="ognl:beans.delegate">
> <table border="0" cellspacing="0" cellpadding="1" align="center"
> class="tablestyle1">
> <tr>
> <td>
> <table width="282" border="0" cellspacing="0" cellpadding="0"
> align="center">
> <tr>
> <td colspan="2" class="fontcontent6">
> <table width="100%" border="0" cellspacing="0" cellpadding="3">
> <tr>
> <td class="maincolor4"><span class="fontcontent2"><b>Change
> Password</b></span></td>
> </tr>
> </table>
> </td>
> </tr>
> <tr>
> <td class="maincolor2" colspan="2" align="center">
> <table width="284" border="0" cellspacing="0" cellpadding="5">
> <tr>
> <td colspan="2"><img src="images/global/spacer.gif" width="1"
> height="1"></td>
> </tr>
> <!-- Begin -->
> <tr>
> <td colspan="2"><span class="message" jwcid="@Insert"
> value="ognl:page.title">Some text here</span></td>
> </tr>
> <tr valign="bottom">
> <td colspan="2" height="15" align="center"><img
> src="images/global/line_spacer1.gif" width="320" height="2"></td>
> </tr>
> <!-- end -->
> <tr>
> <td align="right"><span class="fieldlabel1"><span
> jwcid="@FieldLabel" field="ognl:components.inputCurrentPassword" >Current
> Password</span><span></td>
> <td align="right"><input jwcid="inputCurrentPassword" type="text"
> name="currentPassword" class="formfield1"/></td>
> </tr>
> <tr>
> <td align="right"><span class="fieldlabel1"><span
> jwcid="@FieldLabel"
> field="ognl:components.inputNewPassword">Password</span></span></td>
> <td align="right"><input jwcid="inputNewPassword" type="text"
> name="newPassword" class="formfield1"/></td>
> </tr>
> <tr>
> <td align="right"><span class="fieldlabel1"><span
> jwcid="@FieldLabel" field="ognl:components.inputVerifyPassword"
> class="fieldlabel1">Password</span></span></td>
> <td align="right"><input jwcid="inputVerifyPassword" type="text"
> name="verifyPassword" class="formfield1"/></td>
> </tr>
> <tr>
> <td colspan="2" class="fontcontent3"><img
> src="images/global/spacer.gif" width="1" height="1"></td>
> </tr>
> <tr valign="bottom">
> <td colspan="2" height="15" align="center"><img
> src="images/global/line_spacer1.gif" width="320" height="2"></td>
> </tr>
> <tr>
> <td colspan="2">
> <span jwcid="@ShowError"/>
> </td>
> </tr>
> <tr>
> <td colspan="2">
> <span jwcid="@ShowMessage"/>
> </td>
> </tr>
> <tr>
> <td colspan="2" align="right" height="40">
> <input type="submit" jwcid="@Submit"
> listener="ognl:listeners.changePassword"   disabled="ognl:passwordChanged"
> class="button1" value="OK" />
> &nbsp;&nbsp;
> <input type="submit" jwcid="@Submit"
> listener="ognl:listeners.continueAction"  disabled="ognl:!passwordChanged"
> class="button1" value="Continue" />
> </td>
> </tr>
> </table>
> </td>
> </tr>
> </table>
>   </td>
> </tr>
> </table>
> </form>
> </body>
>
>
>
> and here is my java class
>
> public abstract class ChangePassword extends ProtectedPage implements
> IMessageProperty
> {
> private String m_title ;
>
>     public abstract void setCallback(ICallback value);
>     public abstract ICallback getCallback();
>     public abstract String getCurrentPassword();
>     public abstract void setCurrentPassword(String password);
> public abstract String getNewPassword();
> public abstract void setNewPassword(String value);
> public abstract String getVerifyPassword();
> public abstract void setVerifyPassword(String value);
>
>
> public void setTitle( String title )
> {
> m_title = title ;
> }
>
> public String getTitle()
> {
> Visit v = (Visit)getVisit() ;
> UserToken tok = v.getToken() ;
> if( tok.isChangePassword() == UserToken.PASSWORD_CHANGE_REQ_FIRST_LOGIN )
> m_title =  v.getLocalizer().msg( "PASSWORD_CHANGE_REQ_FIRST_LOGIN") ;
> else if( tok.isChangePassword() == UserToken.PASSWORD_CHANGE_REQ_EXPIRE )
> m_title =  v.getLocalizer().msg( "PASSWORD_EXPIRED_MESSAGE" ) ;
> else
> m_title = v.getLocalizer().msg( "CHANGE_PASSWORD" ) ;
>
> return m_title ;
> }
>
> public void changePassword( IRequestCycle cycle )
> {
> String oldpassword =  getCurrentPassword() ;
> String newpassword = getNewPassword() ;
> String verfiyPassword = getVerifyPassword() ;
>
> IValidationDelegate delegate = getValidationDelegate();
>
> if (delegate.getHasErrors())
> return;
>
> Visit visit = (Visit)getVisit() ;
> FMCEngine fmcEngine = (FMCEngine) getEngine();
>
> if( !newpassword.equals( verfiyPassword ) )
> {
> fmcEngine.presentError( visit.getLocalizer().msg(
> "PASSWORD_MATCH_ERROR_MESSAGE" ), cycle );
> return ;
> }
>
> Users user = new Users() ;
> try
> {
> user.changePassword( visit.getToken(), oldpassword, newpassword );
> visit.getToken().setChangePassword( UserToken.NO_PASSWORD_CHANGE_REQ );
> if( visit.getUser() != null )
> return ;
>
> long userId = ((Long)visit.getToken().getParamater(
> UserToken.USER_ID )).longValue() ;
> UserDTO dto = user.getUser( userId, visit.getToken() ) ;
> visit.setUser( dto );
>
> /*InfoPage page = (InfoPage)cycle.getPage( "InfoPage" ) ;
> page.setMessage( visit.getLocalizer().msg( "PASSWORD_CHANGE_SUCCESS" ) );
> page.setCallback( getCallback() );*/
>
> IMessageProperty page = (IMessageProperty) cycle.getPage( cycle.getPage
> ().getPageName() );
> page.setMessage( visit.getLocalizer().msg( "PASSWORD_CHANGE_SUCCESS" ) );
> cycle.activate( page );
> }
> catch( WillowException e )
> {
> fmcEngine.handleWillowException( e, cycle );
> }
> catch( RemoteException e )
> {
> fmcEngine.rmiFailure( visit.getLocalizer().msg( "PASSWORD_CHANGE_FAIL" ),
> e, 0 );
> }
>
> }
>
> public void continueAction( IRequestCycle cycle )
> {
> FMCEngine engine = (FMCEngine)cycle.getEngine();
> ICallback callback = getCallback();
> if( callback == null )
> cycle.activate( "Home" );
> else
> callback.performCallback(cycle);
>
> engine.forgetPage( getPageName() );
> }
>
> }
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


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


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


Re: Problem with form submit

Posted by Bryan Lewis <br...@maine.rr.com>.
This is only a guess after skimming the code... what's the purpose of that
statement

    engine.forgetPage( getPageName() );

?  Accoring to the API, "All property changes for the page are lost," which
might explain why it doesn't work as expected the second time around.  Does the
page work with that line commented out?


----- Original Message ----- 
From: "Simon Raveh" <Si...@nominum.com>
To: "Tapestry-User" <ta...@jakarta.apache.org>
Sent: Tuesday, September 16, 2003 2:06 PM
Subject: Problem with form submit


> Hi I didn't get any response so I'm trying again.
>
> I have a Change Password form with two buttons OK and Continue. The first
> time the form render itself the OK button is enabled and the Continue button
> is disabled. After the user submit the form and change the password, I
> display the same page again with an info message added to it and switch the
> state of the buttons,
> the OK button is disabled and the Continue button is enabled.
>
> How ever It seems that on the second time the page is being render the
> Continue
> button is not link to my listener, pressing on it does not invoke my
> listener and I can see from the URL that I lost the session id.
> After more Investigations I discover that the problem is the disabled
> attribute in the second submit button ( the continue button ).
> The moment I add the disabled attribute to the second submit button it stops
> working.
>
> The browser renders the buttons correctly but pressing on the button has no
> effect.
>
> Thanks Simon
>
>
> here is my template page.
>
> <body jwcid="@Body">
> <p>&nbsp;</p>
> <p>&nbsp;</p>
> <form jwcid="@Form"  delegate="ognl:beans.delegate">
> <table border="0" cellspacing="0" cellpadding="1" align="center"
> class="tablestyle1">
> <tr>
> <td>
> <table width="282" border="0" cellspacing="0" cellpadding="0"
> align="center">
> <tr>
> <td colspan="2" class="fontcontent6">
> <table width="100%" border="0" cellspacing="0" cellpadding="3">
> <tr>
> <td class="maincolor4"><span class="fontcontent2"><b>Change
> Password</b></span></td>
> </tr>
> </table>
> </td>
> </tr>
> <tr>
> <td class="maincolor2" colspan="2" align="center">
> <table width="284" border="0" cellspacing="0" cellpadding="5">
> <tr>
> <td colspan="2"><img src="images/global/spacer.gif" width="1"
> height="1"></td>
> </tr>
> <!-- Begin -->
> <tr>
> <td colspan="2"><span class="message" jwcid="@Insert"
> value="ognl:page.title">Some text here</span></td>
> </tr>
> <tr valign="bottom">
> <td colspan="2" height="15" align="center"><img
> src="images/global/line_spacer1.gif" width="320" height="2"></td>
> </tr>
> <!-- end -->
> <tr>
> <td align="right"><span class="fieldlabel1"><span
> jwcid="@FieldLabel" field="ognl:components.inputCurrentPassword" >Current
> Password</span><span></td>
> <td align="right"><input jwcid="inputCurrentPassword" type="text"
> name="currentPassword" class="formfield1"/></td>
> </tr>
> <tr>
> <td align="right"><span class="fieldlabel1"><span
> jwcid="@FieldLabel"
> field="ognl:components.inputNewPassword">Password</span></span></td>
> <td align="right"><input jwcid="inputNewPassword" type="text"
> name="newPassword" class="formfield1"/></td>
> </tr>
> <tr>
> <td align="right"><span class="fieldlabel1"><span
> jwcid="@FieldLabel" field="ognl:components.inputVerifyPassword"
> class="fieldlabel1">Password</span></span></td>
> <td align="right"><input jwcid="inputVerifyPassword" type="text"
> name="verifyPassword" class="formfield1"/></td>
> </tr>
> <tr>
> <td colspan="2" class="fontcontent3"><img
> src="images/global/spacer.gif" width="1" height="1"></td>
> </tr>
> <tr valign="bottom">
> <td colspan="2" height="15" align="center"><img
> src="images/global/line_spacer1.gif" width="320" height="2"></td>
> </tr>
> <tr>
> <td colspan="2">
> <span jwcid="@ShowError"/>
> </td>
> </tr>
> <tr>
> <td colspan="2">
> <span jwcid="@ShowMessage"/>
> </td>
> </tr>
> <tr>
> <td colspan="2" align="right" height="40">
> <input type="submit" jwcid="@Submit"
> listener="ognl:listeners.changePassword"   disabled="ognl:passwordChanged"
> class="button1" value="OK" />
> &nbsp;&nbsp;
> <input type="submit" jwcid="@Submit"
> listener="ognl:listeners.continueAction"  disabled="ognl:!passwordChanged"
> class="button1" value="Continue" />
> </td>
> </tr>
> </table>
> </td>
> </tr>
> </table>
>   </td>
> </tr>
> </table>
> </form>
> </body>
>
>
>
> and here is my java class
>
> public abstract class ChangePassword extends ProtectedPage implements
> IMessageProperty
> {
> private String m_title ;
>
>     public abstract void setCallback(ICallback value);
>     public abstract ICallback getCallback();
>     public abstract String getCurrentPassword();
>     public abstract void setCurrentPassword(String password);
> public abstract String getNewPassword();
> public abstract void setNewPassword(String value);
> public abstract String getVerifyPassword();
> public abstract void setVerifyPassword(String value);
>
>
> public void setTitle( String title )
> {
> m_title = title ;
> }
>
> public String getTitle()
> {
> Visit v = (Visit)getVisit() ;
> UserToken tok = v.getToken() ;
> if( tok.isChangePassword() == UserToken.PASSWORD_CHANGE_REQ_FIRST_LOGIN )
> m_title =  v.getLocalizer().msg( "PASSWORD_CHANGE_REQ_FIRST_LOGIN") ;
> else if( tok.isChangePassword() == UserToken.PASSWORD_CHANGE_REQ_EXPIRE )
> m_title =  v.getLocalizer().msg( "PASSWORD_EXPIRED_MESSAGE" ) ;
> else
> m_title = v.getLocalizer().msg( "CHANGE_PASSWORD" ) ;
>
> return m_title ;
> }
>
> public void changePassword( IRequestCycle cycle )
> {
> String oldpassword =  getCurrentPassword() ;
> String newpassword = getNewPassword() ;
> String verfiyPassword = getVerifyPassword() ;
>
> IValidationDelegate delegate = getValidationDelegate();
>
> if (delegate.getHasErrors())
> return;
>
> Visit visit = (Visit)getVisit() ;
> FMCEngine fmcEngine = (FMCEngine) getEngine();
>
> if( !newpassword.equals( verfiyPassword ) )
> {
> fmcEngine.presentError( visit.getLocalizer().msg(
> "PASSWORD_MATCH_ERROR_MESSAGE" ), cycle );
> return ;
> }
>
> Users user = new Users() ;
> try
> {
> user.changePassword( visit.getToken(), oldpassword, newpassword );
> visit.getToken().setChangePassword( UserToken.NO_PASSWORD_CHANGE_REQ );
> if( visit.getUser() != null )
> return ;
>
> long userId = ((Long)visit.getToken().getParamater(
> UserToken.USER_ID )).longValue() ;
> UserDTO dto = user.getUser( userId, visit.getToken() ) ;
> visit.setUser( dto );
>
> /*InfoPage page = (InfoPage)cycle.getPage( "InfoPage" ) ;
> page.setMessage( visit.getLocalizer().msg( "PASSWORD_CHANGE_SUCCESS" ) );
> page.setCallback( getCallback() );*/
>
> IMessageProperty page = (IMessageProperty) cycle.getPage( cycle.getPage
> ().getPageName() );
> page.setMessage( visit.getLocalizer().msg( "PASSWORD_CHANGE_SUCCESS" ) );
> cycle.activate( page );
> }
> catch( WillowException e )
> {
> fmcEngine.handleWillowException( e, cycle );
> }
> catch( RemoteException e )
> {
> fmcEngine.rmiFailure( visit.getLocalizer().msg( "PASSWORD_CHANGE_FAIL" ),
> e, 0 );
> }
>
> }
>
> public void continueAction( IRequestCycle cycle )
> {
> FMCEngine engine = (FMCEngine)cycle.getEngine();
> ICallback callback = getCallback();
> if( callback == null )
> cycle.activate( "Home" );
> else
> callback.performCallback(cycle);
>
> engine.forgetPage( getPageName() );
> }
>
> }
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


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