1

Sometimes, if I click a commandButton that calls an action method, it will just do a page refresh without actually calling the method!

I set a breakpoint in that method and if this behavior takes place, the method is not called. What is also strange about it: It also does that if I didn't fill values in input components that have "required=true". I would expect that a valdiation error appears. The error appears only if the action method would be called fine. But not if it will just issue that strange page refresh.

The call looks pretty normal and works in most cases:

<h:commandButton value="Do something"  
                    action="#{bean.doSomething(someBean.value)}" />  

I can't exactly figure out when this behavior appears (and when not), but it should have something to do with the values chosen in some of the other components. But... how?

(I have two forms in a xhtml file. I just mention that because I don't know if it is important or not. However, there are no nested forms and h:messages displays nothing after page refresh.)

I'm using JSF 2 (MyFaces) + Tomahawk.

geeehhdaa
  • 822
  • 5
  • 17
  • 30

1 Answers1

0

there are no nested forms and h:messages displays nothing after page refresh

You've likely a rendered attribute on the component or one of its parents which evaluated false during the processing of the form submit request. You need to ensure that it evaluates the same as it did during displaying the page. You can do this by putting the bean responsible for this in the view scope instead of the request scope.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • So you were using the `rendered` attribute? If it doesn't work then you're apparently doing business inside the getter instead of in an action/event method. Fix that as well http://stackoverflow.com/questions/2090033/why-jsf-calls-getters-multiple-times – BalusC May 20 '11 at 12:34