Error trying to execute method after error catch
I have this jsf code
<h:form>
<h:inputText value="#{agreement.serviceId}"/>
<h:commandButton value="Enter" action="#{agreement.build}" />
<h:form rendered="#{!agreement.valid}">
<h:outputText value="Service id not valid. Please try again"/>
</h:form>
<h:form>
This is the scoped bean's build method.
private String build(){
try{
...//lots of backend logic
valid = true;
return "/agreementDetail.xhtml?faces-redirect=true";
}catch(Exception e){
valid = false;
return null;
}
}
Basically, here's the behavior I need:
The user inputs a serviceId. If this service id is valid, it redirects the
user to the agreementDetail.xhtml page. If false, the user remains in the
main.xhtml page and the "Service id not valid..." message is rendered.
This is what's happening:
If the user inputs a correct service id, everything works fine. If the
user returns to main.xhtml and inputs an incorrect service id, the error
is displayed correctly. But now, if the user inputs a correct service id,
the build() method is not executed. (I've confirmed this with logging).
Basically, once the user inputs a wrong value, the build() method won't be
executed ever again unless the user signs off and signs in again. Clearly,
something's going on when the build() finds an error and catches the
exception.
Any ideas?
No comments:
Post a Comment