11 Replies Latest reply on Oct 8, 2007 4:07 AM by nagypalg

    commandLink and commandButton do not work in a tabPanel usin

      When I updated from richfaces 3.0.1 to 3.1 I noticed the following problem: if I have a tabPanel that uses the selected tab attribute, commandLink and commandButton components that are in a tab just stop working. With "stop working" I mean that the action method is not invoked at all, and after clicking the link/button the same page is rendered again. Neither h:commandLink nor a4j:commandLink (and ...Button) work. Interestingly, s:link (the Seam link component) does.

      When I remove the selectedTab attribute, the commandLinks (and Buttons) start working again. However, it would be very important for me that the tabPanel remembers its state. Any ideas on that, why it does not work? Is it a bug?

        • 1. Re: commandLink and commandButton do not work in a tabPanel

          An addition: I also tried using the value attribute of tabPanel, with the same result: no commandLinks or commandButtons work.

          • 2. Re: commandLink and commandButton do not work in a tabPanel

            code snippet is required.

            • 3. Re: commandLink and commandButton do not work in a tabPanel
              ilya_shaikovsky

              Agree with Sergey. B.t.w. I have an example with selectedTab created for another thread and its works on GA.

              • 4. Re: commandLink and commandButton do not work in a tabPanel

                Hi,

                Sorry, it took a while to track down the problem. So, I use Seam 2 CR1 which ships with a fairly new Richfaces version: 3.1.1-SNAPSHOT. It seems that the problem has something to do with storing the tab state in conversational beans. Test code:

                /tabTest.xhtml:

                <f:view xmlns="http://www.w3.org/1999/xhtml"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns:h="http://java.sun.com/jsf/html"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:s="http://jboss.com/products/seam/taglib"
                 xmlns:c="http://java.sun.com/jstl/core"
                 xmlns:a="https://ajax4jsf.dev.java.net/ajax"
                 xmlns:rich="http://richfaces.ajax4jsf.org/rich" contentType="text/html">
                 <html>
                 <head>
                 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                 <title>Tab Tester</title>
                 </head>
                
                 <body>
                
                
                 <h:form>
                 <h:commandLink action="#{tabTestAction.test}" value="Test!" />
                 </h:form>
                
                 <!-- Tab panel test -->
                
                
                 <rich:tabPanel switchType="server"
                 value="#{tabTestAction.selectedTab}">
                
                 <rich:tab label="One" id="coreTab">
                 <h:outputText value="Action: #{tabTestAction}" />
                 <h:form>
                 <h:commandLink action="#{tabTestAction.test}" value="Test!" />
                 </h:form>
                 </rich:tab>
                 <rich:tab label="Two" id="extTab">
                 <h:outputText value="Action: #{tabTestAction}" />
                 <h:form>
                 <h:commandLink action="#{tabTestAction.test}" value="Test!" />
                 </h:form>
                 </rich:tab>
                 </rich:tabPanel>
                
                 </body>
                 </html>
                 </f:view>


                TabTestAction.java:
                @Name("tabTestAction")
                @Scope(ScopeType.CONVERSATION)
                public class TabTestAction {
                
                 @Logger
                 Log log;
                
                // @In FacesMessages facesMessages;
                
                 public String test() {
                 log.debug("Test!!!");
                 return null;
                 }
                
                 private String selectedTab = "coreTab";
                
                 public String getSelectedTab() {
                 log.debug("Getting selected tab: #0", selectedTab);
                 return selectedTab;
                 }
                
                 public void setSelectedTab(String selectedTab) {
                 log.debug("Setting selected tab to: #0", selectedTab);
                 this.selectedTab = selectedTab;
                 }
                
                
                }


                The link outside the tabPanel works, the links inside do not work, the action method is not invoked.

                Now, if I put the tabTestAction in session scope, the example start working. However, when you have any Seam components injected into the component (uncomment @In facesMessages), it stops working again: you get

                org.jboss.seam.RequiredException: In attribute requires non-null value: tabTestAction.facesMessages


                I am not sure, whether it is a Seam bug, or a Richfaces bug...

                • 5. Re: commandLink and commandButton do not work in a tabPanel

                  Some additional information: with the exact same installation, but replacing the richfaces JARs with
                  richfaces-3.0.1.jar
                  ajax4jsf-1.1.1.jar

                  the example works. Based on the log files, it seems that one big difference is that with the older richfaces the getter/setter of the tab state is not invoked when clicking on the commandLink. With the 3.1 version it is different, the getter/setter invoked each time you click on the link.

                  • 6. Re: commandLink and commandButton do not work in a tabPanel
                    maksimkaszynski

                    Correct.
                    Since 3.1 selectedTab is read-write, so one can get selected tab at once in his code.

                    • 7. Re: commandLink and commandButton do not work in a tabPanel

                      Yes, but in the example I use the value attribute and not the selectedTab attribute. And the value attribute was already read/write in the 3.0.1 version, at least the setter gets called properly, so you can read the current tab from code.

                      To me it seems that something was changed in the tabPanel implementation that makes it incompatible with Seam: it seams to me that the setter gets called before the Seam context is initialized, and therefore the JSF lifecycle does not run properly. I am not sure, however, whether it is a problem with Seam or with Richfaces. And of course I am not sure, whether someone else experiences the same problem. Should I file a bug report?

                      • 8. Re: commandLink and commandButton do not work in a tabPanel
                        brooksl

                        I was having the same problem. I added a t:saveState that kept the selectedTab value for the panel and everything works again.

                        • 9. Re: commandLink and commandButton do not work in a tabPanel
                          szaccaria

                          So do I having the same problem... some news about?

                          • 10. Re: commandLink and commandButton do not work in a tabPanel
                            szaccaria
                            • 11. Re: commandLink and commandButton do not work in a tabPanel

                              And there is a workaround posted there. It works both for tabPanels using "selectedTab" and "value".