0

Here is the simplified version of my xhtml code, I can't figure out why my save1 commandButton doesn't work while save2 works:

   <rich:panel id="table_panel">
    <h:form>
    <rich:panel rendered="#{bean.showPanel}">
        <a4j:commandButton id="save1" value="Save" 
            action="#{bean.executeAction()}">
       </rich:panel>
       <rich:panel>
        <a4j:commandButton id="save2" value="Save2" 
            action="#{bean.executeAction()}">
       </rich:panel>
      </h:form>
    </rich:panel>

When click a button, it will update showPanel value to true in backend and re-render *table_panel*, then commandButton save1 will show up, but even if it show up, the action executeAction() will never be invoked after click (never enter into my breakpoint in the method). However, the commandbutton save2 can always act normally.

The only difference for those two buttons is their wrapper rich:panel, one is always there while another is displayed after some UI action as it has rendered="#{bean.showPanel}" attribute. I didn't see any javascript errors on firebug.

I would appreciate any ideas, thanks in advance!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Paul Lo
  • 6,032
  • 6
  • 31
  • 36
  • Thanks for the useful link, that fifth possibility looks close to my issue. However, I haven't figured out a way to get around. – Paul Lo Nov 06 '13 at 11:26
  • What scope is bean in? If bean is request scoped, the `#{bean.showPanel}` is reinitialized to default when the bean is newly recreated during processing the form submit. This construct requires at least a view scoped bean, or you must maintain the state in bean's (post)constructor based on request parameters. The answer at point 5 is pretty explicit in this. I'm not sure what part you didn't understood and why you still didn't tell anything about the bean's scope after reading that. – BalusC Nov 11 '13 at 11:36
  • 1
    Looks like the issue goes away when I extend the scope of bean from Page to Session (I'm using Seam framework), I just realized it didn't work because I accidentally made another mistake. Thanks. – Paul Lo Nov 13 '13 at 15:21

2 Answers2

1

Try putting execute="@this" explicitly in the commandButton.

Amit Tikoo
  • 167
  • 6
1

Have you tried immediate="true", it might narrow down the issue in my opinion:

<a4j:commandButton id="save1" value="Save" immediate="true"
    action="#{bean.executeAction()}">
b937 r977
  • 45
  • 5