I currently have the following problem with Apache Tapestry 5.3.1: The user should be able to edit his profile details and to change his password. For the data there is a "User" entity.
I cannot use the getPassword method of user, as passwords are stored encrypted with a salt that always changes (using Apache Tynamo). As a result, I am trying to store the values in two page properties called passwordValue1 and passwordValue2 and use the rest of the bean. On validations both passwordValue fields are null, even if I typed something and then submitted the form. Any ideas why?
<t:beaneditform object="currentUserInfo" add="password1,password2" t:id="registerForm"
exclude="username,password,accountLocked,credentialsExpired">
<p:password1>
<t:label for="password1" >Passwort</t:label>
<t:passwordfield t:id="password1" value="passwordValue1" validate="password"/>
</p:password1>
<p:password2>
<t:label for="password2" >Passwort wiederholen</t:label>
<t:passwordfield t:id="password2" value="passwordValue2" validate="password"/>
</p:password2>
</t:beaneditform>
The java code for the tapestry page:
@RequiresUser
public class UserDetails {
@InjectPage
private Index index;
@Inject
UserUtility userUtil;
@Inject
private Session session;
@Inject
@Property
@SessionState(create = false)
private User currentUserInfo; //value is set
@Component(id="password1")
private PasswordField password1;
@Component(id="password2")
private PasswordField password2;
@Property
private String passwordValue2;
@Property
private String passwordValue1;
@InjectComponent
private BeanEditForm registerForm;
//...snip....
void onValidate() {
System.out.println("onvalidate");
if (registerForm.getHasErrors()) {
return;
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// both passwordValue1 and passwordValue 2 are null here
if ((passwordValue1 == null && !("".equals(passwordValue1))
|| !passwordValue1.equals(passwordValue2))) {
registerForm.recordError(password1, "Passwords must match");
registerForm.recordError(password2, "Passwords must match");
}
}