Announcement Announcement Module
Collapse
No announcement yet.
Spring Roo update.jspx @Transient password field - can't get it work Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Roo update.jspx @Transient password field - can't get it work

    My Roo-generated (Web MVC, Hibernate) Person class has a @PreUpdate @PrePersist method, added by me, used to encrypt password before storing user data in the database. This methods compares password and passwordConfirmation (@Transient) form fields, and if they are equal, encrypts password. In the create.jspx everything works fine. But update.jspx doesn't pass the passwordConfirmation form value into the Person.passwordConfirmation. Where I am wrong?
    update.jspx :
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <div xmlns:field="urn:jsptagdir:/WEB-INF/tags/form/fields" 
    xmlns:form="urn:jsptagdir:/WEB-INF/tags/form" 
    xmlns:jsp="http://java.sun.com/JSP/Page" 
    xmlns:spring="http://www.springframework.org/tags" version="2.0">
        <jsp:directive.page contentType="text/html;charset=UTF-8"/>
        <jsp:output omit-xml-declaration="yes"/>
        <form:update id="fu_ru_dp_person_domain_Person" 
        idField="idperson" modelAttribute="person" 
        path="/persons" 
        versionField="none" z="Qhcf0JCeZUC6aMA3/6/5aDbQ13g=">
    ...
            <field:input field="password" id="c_ru_dp_person_domain_Person_password" required="true" type="password"  z=""/>
            <field:input field="passwordConfirmation" id="c_ru_dp_person_domain_Person_passwordConfirmation" required="true" type="password" z=""/>
    create.jspx:
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <div xmlns:c="http://java.sun.com/jsp/jstl/core" 
    xmlns:field="urn:jsptagdir:/WEB-INF/tags/form/fields" 
    xmlns:form="urn:jsptagdir:/WEB-INF/tags/form" 
    xmlns:jsp="http://java.sun.com/JSP/Page" 
    xmlns:spring="http://www.springframework.org/tags" version="2.0">
        <jsp:directive.page contentType="text/html;charset=UTF-8"/>
        <jsp:output omit-xml-declaration="yes"/>
        <form:create id="fc_ru_dp_person_domain_Person" 
        modelAttribute="person" path="/persons" 
        render="${empty dependencies}" z="+YEbyTqiV2xT0u7rtPVJy3fd4Zw=">
            ...
            <field:input field="password" id="c_ru_dp_person_domain_Persons_password" required="true" type="password" z=""/>
            <field:input field="passwordConfirmation" id="c_ru_dp_person_domain_Person_passwordConfirmation" required="true" type="password" z="user-managed"/>
    Person.java :
    Code:
    @PrePersist
        @PreUpdate
        protected void encryptPassword() {
            String pwd = this.getPassword(), pwd2 = this.getPasswordConfirmation();
            if (pwd2 != null && pwd.equals(pwd2)) {
                this.setPassword(passwordEncoder.encodePassword(pwd, null));
            }
        }
Working...
X