-
1. Re: a4j and jsf locale change problem
nbelaevski Apr 6, 2009 5:58 PM (in response to janusz.gren)Hello,
You can make h:inputText immediate="true". This will cause validation to trigger for immediate action components also. -
2. Re: a4j and jsf locale change problem
janusz.gren Apr 7, 2009 12:05 AM (in response to janusz.gren)Hello,
Thanks for the idea - it does not however solve the problem.
The thing is that the ajax component which is triggered by an onblur event retrieves the error message from a .properties file and it does not automatically react to locale change. The message gets properly adjusted to the correct locale after I trigger the onblur event myself manually.
Maybe there is some way to trigger this event from the commandLinks straight after the locale change?
Thanks
Janusz -
3. Re: a4j and jsf locale change problem
nbelaevski Apr 7, 2009 5:31 AM (in response to janusz.gren)Janusz,
Please post bean code. And what is bean scope? -
4. Re: a4j and jsf locale change problem
janusz.gren Apr 7, 2009 6:09 AM (in response to janusz.gren)the userBean ajax validation code :
private String errorMessage = null;
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public void validateName(ActionEvent e) {
UIInput input = (UIInput)e.getComponent() // Ajax4jsf comp
.getParent(); // input comp
if (input != null) {
String name = (String)input.getSubmittedValue();
if (name != null) {
//do something
FacesContext fc = FacesContext.getCurrentInstance();
input.validate(fc); // iterates over input's validators
if ( ! input.isValid())
setErrorMessage(fc, input);
}
}
}
private void setErrorMessage(FacesContext fc, UIInput input) {
Iterator it = fc.getMessages(input.getClientId(fc));
if (it.hasNext()) {
FacesMessage facesMessage = (FacesMessage)it.next();
errorMessage = facesMessage.getSummary();
}
}
This code is triggered by an onblur event on the firstNameInput field and the errorMessage is retrieved from the errorMessage property.
Now when the commandLink changes the locale the JSF changes all of the labels which directly access their strings via eg. #{msgs.firstName}, however since the errorMessage is taken from the bean property - it does not get changed automatically
Janusz -
5. Re: a4j and jsf locale change problem
janusz.gren Apr 7, 2009 6:10 AM (in response to janusz.gren)forgot to add that both the userBean and changelocaleBean are session scoped.
-
6. Re: a4j and jsf locale change problem
nbelaevski Apr 7, 2009 6:46 AM (in response to janusz.gren)I think the best you can do are two things: either a) call validating actions programmatically on locale switch
or b) use more common way of validation