[
http://issues.apache.org/jira/browse/MYFACES-214?page=comments#action_65593 ]
Philipp Ahlner commented on MYFACES-214:
----------------------------------------
I've overwritten HtmlTabbedPaneRenderer and implemented a own decode (and not
encodeChildren as mentioned in my previos comment - it was a mistake) method.
The decode calls super and after that fakeSubmittedValue(...). This method
iterates over the component tree and sets submittedValue of all UIInput
comonents to value and if value null to an empty string. If a other value is
submitted, the decode methods of the component will overwrite the value wich is
set by my patch.
/**
*
*/
package org.ahlner.jsf.myfaces.ext.tabbedpane;
import java.util.Iterator;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import org.apache.myfaces.custom.tabbedpane.HtmlTabbedPaneRenderer;
/**
* @author ahlner
*/
public class TabbedPaneRenderer extends HtmlTabbedPaneRenderer
{
public void decode(FacesContext facesContext, UIComponent uiComponent)
{
super.decode(facesContext, uiComponent);
fakeSubmittedValue(uiComponent);
}
private void fakeSubmittedValue(UIComponent component)
{
if (component instanceof UIInput)
{
UIInput input = (UIInput) component;
// set initial to the value-property
if (input.getSubmittedValue() == null)
{
input.setSubmittedValue(input.getValue());
}
// the value-property was null, init with an empty string by default
if (input.getSubmittedValue() == null)
{
input.setSubmittedValue("");
}
}
// process children
Iterator children = component.getChildren().iterator();
while (children.hasNext())
{
Object object = children.next();
UIComponent child = (UIComponent) object;
fakeSubmittedValue(child);
}
}
}
I will test my patch in the next days/weeks.
> TabbedPane : wrong validation behavior
> --------------------------------------
>
> Key: MYFACES-214
> URL: http://issues.apache.org/jira/browse/MYFACES-214
> Project: MyFaces
> Type: Bug
> Versions: 1.0.9 beta
> Environment: MyFaces 1.0.9rc3, Tomcat 5.0.27, j2sdk1.5.0_01
> Reporter: Philipp Ahlner
>
> Requirements for reproduction:
> - min. two tabs with min. one required Input-Fields
> - a submit button on each tab
> - an "<h:messages styleClass="errors" showDetail="true"
> showSummary="true"/>"-tag to see all validation errors regardless which tab
> is selected
> Expected behavior:
> - if the submit button is pressed, !both! fields should be validated
> regardless which tab is selected
> Steps to reproduce:
> 1. start a new session
> 2. let the required text fields empty
> 3. press the submit button in the first tab.
> Behavior:
> Only the field(s) on the first tab is validated.
> The interesting effect:
> Select the second tab and press submit. The validation errors on !both! tab
> occours. If the tab was
> activated at least one time in a new session, all fields were validated
> correctly.
> Further informations:
> http://www.mail-archive.com/users%40myfaces.apache.org/msg03525.html
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira