Philipp,
As a workaround for what I believe is the same problem, we
are listening on tab change events and setting all the
vales & submitted values of all the contained components to
null. We have that luxury because each panel is
self-contained (i.e. any changes inside a tab are lost if
the tab is changed without clicking save)
-- Jon
On May 20, 2005, at 4:06 AM, Philipp Ahlner wrote:
2005/5/20, Martin Marinschek <[EMAIL PROTECTED]>:
Now what happens when a component is not rendered at all and
returns a
null value - you validate it anyways?
No, the processDecodes method in UIInput checks, if the component is
rendered or not and
calls validate only if rendered is true. I only set the submittedValue
of the component to
simulate a submit for the components on a hidden tab-pane.
Shouldn't only those components who submit a value be validated?
Yes, as we can read in the spec - but the the TabbedPane component
submits only the
components on the visible pane. The invisible components are not
submitted. The behavior without my patch is crazy (see bug
description) and a real blocker for my project.
Regards,
Philipp
regards,
Martin
On 5/20/05, Philipp Ahlner (JIRA) <myfaces-
[EMAIL PROTECTED]> wrote:
[ http://issues.apache.org/jira/browse/MYFACES-214?
page=comments#action_65833 ]
Philipp Ahlner commented on MYFACES-214:
----------------------------------------
Since submittedValue should be a String some converting-jobs are
to do. A improved patch is following, I hope someone is interested.
/**
*
*/
package de.interforum.jsf.myfaces.ext.tabbedpane;
import java.util.Iterator;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
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(facesContext, uiComponent);
}
private void fakeSubmittedValue(FacesContext context,
UIComponent component)
{
if (component instanceof UIInput)
{
UIInput input = (UIInput) component;
// set initial to the value-property
if (input.getSubmittedValue() == null)
{
Converter converter = input.getConverter();
Object value = input.getValue();
if (converter == null && value != null)
{
try
{
converter = context.getApplication
().createConverter(
value.getClass());
} catch (FacesException e)
{
context.getExternalContext().log(
"No converter for class "
+ value.getClass().getName()
+ " found (component id="
+ component.getId() +
").", e);
}
}
if (converter == null)
{
if (value != null)
{
if (value instanceof String)
{
input.setSubmittedValue(value);
}
else
{
input.setSubmittedValue(value.toString
());
}
}
else
{
// the value-property was null, init with
an empty
// string by default
input.setSubmittedValue("");
}
}
else
{
Object convertedValue = converter.getAsString
(context, component, value);
input.setSubmittedValue(convertedValue);
}
}
}
// process children
Iterator children = component.getChildren().iterator();
while (children.hasNext())
{
Object object = children.next();
UIComponent child = (UIComponent) object;
fakeSubmittedValue(context, child);
}
}
}
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