0

I have a datatable with a checkbox in all rows and I have a commandButton at the bottom. If the user has not selected any row and then clicks the commandButton he gets an error message.

My issue here is: When the user has not selected anything and clicks the commandButton (for the first time), h:message appears.
After that if the commandButton is clicked again the action method displayStruct is not invoked. If the user then selects a row and clicks the commandButton it works.

Next time if he does not select a row it shows error message (again). After that if he selects the row then it works (again).

So, the thing is if the user does not select any row for the first time, after that for any number of time the commandButton is not getting invoked.#

Here is my code

<p:commandButton 
    value="Compare" 
    action="#{historyOrgStructController.displayStruct}"
    update=":form" oncomplete="orgStructDialog.show()"  
    title="View Detail" />

<p:dialog 
    id="dialog" 
    header="History on the selected Dates" 
    widgetVar="orgStructDialog"
    showEffect="slide" 
    hideEffect="slide" 
    rendered="#{historyOrgStructController.flag}" /> 
Jens
  • 5,895
  • 1
  • 46
  • 73
Karthik
  • 21
  • 7
  • Would be easier to understand if you show more view code, ie : all relevant parts of it. – Alexandre Lavoie May 30 '13 at 11:20
  • thanks for your reply..i've added dialog for it – Karthik May 30 '13 at 11:56
  • 1
    I was more thinking about posting in the question dataTable, h:message, etc so almost all the view code. The `historyOrgStructController` bean code should be interresting too. – Alexandre Lavoie May 30 '13 at 12:13
  • I think that is normal behavior. If the validation in JSF finds an error (in your case: User has not selected any row) the JSF lifecycle will not execute the "invoke application" phase. That is where your action method from the `commandButton` is called. Please check out [this excellent answer](http://stackoverflow.com/a/2120183/332248) from BalusC. Especially No 3. – Jens May 30 '13 at 15:39
  • @Karthik you need to add more context to your question and your code. It's reasonable to expect that whatever is affecting the command button is not the command button itself. My guess would be your use of ``. Do you have nested forms? – kolossus Jun 02 '13 at 14:31

0 Answers0