yes, I used that version - that seems to be the problem,
HtmlSelectBooleanCheckbox expects a boolean value as submitted value?
regards,
Martin
On 5/21/05, Philipp Ahlner <[EMAIL PROTECTED]> wrote:
> Hi!
>
> On yesterday I've submitted a improved patch. Did you using the newest
> version (which calls the corresponding converter to convert the value
> to a string)??
>
> Here is the version again:
>
>
> /**
> *
> */
> 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);
> }
> }
> }
>
> 2005/5/21, Martin Marinschek <[EMAIL PROTECTED]>:
> > I get the following exception when I submit the values and go to the
> > third page of the MyFaces tabbedPane example when I use your patch:
> >
> > javax.faces.FacesException: Expected submitted value of type Boolean
> > for component : {Component-Path : [Class:
> > javax.faces.component.UIViewRoot,ViewId: /tabbedPane.jsp][Class:
> > org.apache.myfaces.custom.layout.HtmlPanelLayout,Id: page][Class:
> > javax.faces.component.html.HtmlPanelGroup,Id: body][Class:
> > org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPane,Id:
> > _id4][Class: org.apache.myfaces.custom.tabbedpane.HtmlPanelTab,Id:
> > tab3][Class: org.apache.myfaces.component.html.ext.HtmlDataTable,Id:
> > xxx][Class: javax.faces.component.UIColumn,Id: _id18][Class:
> > javax.faces.component.html.HtmlSelectBooleanCheckbox,Id: _id20]}
> >
> > org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:411)
> >
> > org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:225)
> >
> > Can you check that?
> >
> > regards,
> >
> > Martin
> >
> > On 5/21/05, Martin Marinschek <[EMAIL PROTECTED]> wrote:
> > > ---------- Forwarded message ----------
> > > From: Martin Marinschek <[EMAIL PROTECTED]>
> > > Date: May 21, 2005 10:32 PM
> > > Subject: Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong
> > > validation behavior
> > > To: Philipp Ahlner <[EMAIL PROTECTED]>
> > >
> > >
> > > Ok, I see.
> > >
> > > then I will submit your patch and try out if everything works on the
> > > tabbed-pane example page of MyFaces.
> > >
> > > I will commit it if that is true, if not I will come back to you and
> > > tell you about that...
> > >
> > > regards,
> > >
> > > Martin
> > >
> > > On 5/21/05, Philipp Ahlner <[EMAIL PROTECTED]> wrote:
> > > > Hi Martin!
> > > >
> > > > If you only change the tab, no validation is done. A click on a flap
> > > > of the tab is like a click on a x:commandButton with immediate="true"
> > > > (it's not really the same, but the same behavior).
> > > >
> > > > Regards,
> > > > Philipp
> > > >
> > > > 2005/5/21, Martin Marinschek <[EMAIL PROTECTED]>:
> > > > > Another problem: what if initially several components on several pages
> > > > > are invalid - now you can never change to another tab with your
> > > > > approach, as the validation prevents the navigation to get through?
> > > > >
> > > > > regards,
> > > > >
> > > > > Martin
> > > > >
> > > > > On 5/21/05, Philipp Ahlner <[EMAIL PROTECTED]> wrote:
> > > > > > Hi Jon!
> > > > > >
> > > > > > I think there are two main strategies with the tabbed-panes. Either
> > > > > > all components
> > > > > > are treated together regardless on which tab they are shown (like
> > > > > > mine), or they are treated tab by tab (like yours). Your idea to
> > > > > > handle this problem in a listener is a very good one.
> > > > > >
> > > > > > Regards,
> > > > > > Philipp
> > > > > >
> > > > > > 2005/5/21, Jon Travis <[EMAIL PROTECTED]>:
> > > > > > > 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
> > > > > > > >>>
> > > > > > > >>>
> > > > > > > >>>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
>
>