On 10/5/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > [EMAIL PROTECTED] wrote on 10/05/2005 05:48:57 PM: > > > > > Right strategy ... but one wrong detail. The search expression for > > findComponent() is the *client id* of the component in question, not the > > *id* property value. In turn, the client id will be affected by the id > of > > naming containers (such as the <h:form> component) that your input field > is > > nested in. Quickest way to see what value you should use is to do a View > > Source on the HTML page, and see what id was emitted for the input > field. > > > > A different approach that will often be easier, though, is to use the > > "binding" attribute to bind an instance of your actual component into > the > > backing bean. In the JSP page, you can say: > > > > <h:inputSecret id="password" binding="#{backingBean.password}" .../> > > > > and in the managed bean labelled by "backingBean" (the same one where > you do > > your authentication check): > > > > private HtmlInputSecret password = null; > > public HtmlInputSecret getPassword() { return this.password; } > > public void setPassword(HtmlInputSecret password) { this.password = > > password; } > > > > ok, here's the relevant code now: > > RegistrationBean (backingbean) has: > > private HtmlInputSecret password = null; > private HtmlInputSecret password2 = null; >
Do you have the corresponding public getter and setter methods? (At least getPassword() and setPassword())? Otherwise, this instance variable will never be initialized. Craig > That way, the code that calls error() has direct access to the actual > > component instance, and does not have to look it up. > > public String save() { > .. > if (!(password.equals(password2))) { > error(password, messages.getMessage("password.mismatch")); > *// I assume this is what you by your comment above..?* > } > .. > }//end save > > Finally, My registration.jsp has: > <h:inputSecret id="password" required="true" binding="#{ > registration.password}" /> > <h:message for="password" /> > > What have I missed? Since the error still doesn't show up.. > > > > > Craig > > > > Thanks again, > Geeta