button with defaultCommand="true" and tabGroup with switchType="client" shows wrong/unexpected behaviour --------------------------------------------------------------------------------------------------------
Key: TOBAGO-871 URL: https://issues.apache.org/jira/browse/TOBAGO-871 Project: MyFaces Tobago Issue Type: Bug Affects Versions: 1.0.24 Environment: Ubuntu 9.04, Tomcat 6.0, Firefox 3.0.18 Reporter: D. W. Dear all, When the attribute defaultCommand="true" for a tc:button is combined with tc:tabGroup and attribute switchType="client" (i.e. the default value), a wrong/unexpected behaviour is noticed. Please consider the following code and read the more detailed explanations below: Backing Bean: TestDefaultCommand.java ------------------------------------------ public class TestDefaultCommand { public String value1; public String value2; public String value3; public String message; public String getValue1() { return value1; } public void setValue1(String value1) { this.value1 = value1; } public String getValue2() { return value2; } public void setValue2(String value2) { this.value2 = value2; } public String getValue3() { return value3; } public void setValue3(String value3) { this.value3 = value3; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public String go1() { setMessage("action of button in tab 1 invoked - value: " + getValue1()); return null; } public String go2() { setMessage("action of button in tab 2 invoked - value: " + getValue2()); return null; } public String go3() { setMessage("action of button in tab 3 invoked - value: " + getValue3()); return null; } } ------------------------------------------ JSP-File: testDefaultCommand.jsp ------------------------------------------ <?xml version="1.0" encoding="UTF-8" ?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:f="http://java.sun.com/jsf/core" xmlns:tc="http://myfaces.apache.org/tobago/component" xmlns:tx="http://myfaces.apache.org/tobago/extension" version="2.0"> <f:view> <tc:page label="Default Command Test"> <f:facet name="layout"> <tc:gridLayout rows="fixed;*"/> </f:facet> <tc:cell> <tc:out value="#{testDefaultCommand.message}"/> </tc:cell> <tc:tabGroup> <tc:tab label="Tab 1"> <f:facet name="layout"> <tc:gridLayout rows="fixed;fixed"/> </f:facet> <tx:in value="#{testDefaultCommand.value1}" label="Text: " /> <tc:button action="#{testDefaultCommand.go1}" label="Test 1" /> </tc:tab> <tc:tab label="Tab 2"> <f:facet name="layout"> <tc:gridLayout rows="fixed;fixed"/> </f:facet> <tx:in value="#{testDefaultCommand.value2}" label="Text: " /> <tc:button defaultCommand="true" action="#{testDefaultCommand.go2}" label="Test 2" /> </tc:tab> <tc:tab label="Tab 3"> <f:facet name="layout"> <tc:gridLayout rows="fixed;fixed"/> </f:facet> <tx:in value="#{testDefaultCommand.value3}" label="Text: " /> <tc:button defaultCommand="true" action="#{testDefaultCommand.go3}" label="Test 3" /> </tc:tab> </tc:tabGroup> </tc:page> </f:view> </jsp:root> ------------------------------------------ Faces-config: excerpt ------------------------------------------ ... <managed-bean> <managed-bean-name>testDefaultCommand</managed-bean-name> <managed-bean-class>TestDefaultCommand</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> ... ------------------------------------------ All the scenarios are executed in the listed order: Scenario 1: works as expected Action: In Tab 1, the user enters "a" in input field and clicks on button "Test 1". Expected output: "action of button in tab 1 invoked - value: a" Actual output: "action of button in tab 1 invoked - value: a" Scenario 2: doesn't work as expected Action: In Tab 2, the user enters "b" in input field and clicks on button "Test 2". Expected output: "action of button in tab 2 invoked - value: b" Actual output: "action of button in tab 3 invoked - value: " Scenario 3: works as expected Action: In Tab 3, the user enters "c" in input field and clicks on button "Test 3". Expected output: "action of button in tab 3 invoked - value: c" Actual output: "action of button in tab 3 invoked - value: c" Scenario 4: doesn't work as expected Action: In Tab 1, there is still the value "a" in the text field and the user sets the cursor in the text field and hits "enter". Expected output: "action of button in tab 1 invoked - value: a" Actual output: "action of button in tab 3 invoked - value: c" Scenario 5: doesn't work as expected Action: In Tab 2, there is still the value "b" in the text field and the user sets the cursor in the text field and hits "enter". Expected output: "action of button in tab 2 invoked - value: b" Actual output: "action of button in tab 3 invoked - value: c" Scenario 4: works as expected (by accident) Action: In Tab 3, there is still the value "c" in the text field and the user sets the cursor in the text field and hits "enter". Expected output: "action of button in tab 3 invoked - value: c" Actual output: "action of button in tab 3 invoked - value: c" These scenarios show that there is certainly something wrong with the defaultCommand invocation. It seems that the defaultCommand in Tab 2 gets overwritten by the default command in Tab 3. However, this is an unexpected behavior, since the tabs should function independently of each other and hence should also have the possibility to take independent defaultCommand buttons. Important note: If the attribute "switchType" is set to "reloadTab", all the scenarios work as expected. I am looking forward to any comments on this issue. Many thanks, dw. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.