You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Philipp Ahlner (JIRA)" <my...@incubator.apache.org> on 2005/04/25 20:52:24 UTC

[jira] Created: (MYFACES-214) TabbedPane : wrong validation behavior

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


tomahawk TabbedPane with bgcolor: incomplete style in output header

Posted by Bogdan Sava <bo...@sava.ro>.
Hi,

panelTabbedPane with bgcolor attribute value set, 
does not set bgcolor for the active header input cell .

Header page of a page that contain an panelTabbedPane with 
bgcolor="#FFFFCC" I found :

<style type="text/css">#idTab .myFaces_panelTabbedPane_activeHeaderCell 
input,
#idTab .myFaces_panelTabbedPane_pane,
#idTab .myFaces_panelTabbedPane_subHeaderCell{
background-color:#FFFFCC;
}
</style>

should be (added line for  myFaces_panelTabbedPane_activeHeaderCell):

<style type="text/css">#idTab .myFaces_panelTabbedPane_activeHeaderCell,
#idTab .myFaces_panelTabbedPane_activeHeaderCell input,
#idTab .myFaces_panelTabbedPane_pane,
#idTab .myFaces_panelTabbedPane_subHeaderCell{
background-color:#FFFFCC;
}
</style>

I use nightly 20050827.

Bogdan Sava




tomahawk TabbedPane with bgcolor: incomplete style in output header

Posted by Bogdan Sava <bo...@sava.ro>.
Hi,

panelTabbedPane with bgcolor attribute value set, 
does not set bgcolor for the active header input cell .

Header page of a page that contain an panelTabbedPane with 
bgcolor="#FFFFCC" I found :

<style type="text/css">#idTab .myFaces_panelTabbedPane_activeHeaderCell 
input,
#idTab .myFaces_panelTabbedPane_pane,
#idTab .myFaces_panelTabbedPane_subHeaderCell{
background-color:#FFFFCC;
}
</style>

should be (added line for  myFaces_panelTabbedPane_activeHeaderCell):

<style type="text/css">#idTab .myFaces_panelTabbedPane_activeHeaderCell,
#idTab .myFaces_panelTabbedPane_activeHeaderCell input,
#idTab .myFaces_panelTabbedPane_pane,
#idTab .myFaces_panelTabbedPane_subHeaderCell{
background-color:#FFFFCC;
}
</style>

I use nightly 20050827.

Bogdan Sava




Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Enrique Medina <e....@gmail.com>.
Hi Martin,

I was already using the tabbed panel with nested <x:dataTable> tags
without problems apparently.

What has been the bug fixed regarding this issue?

On 5/22/05, Martin Marinschek <ma...@gmail.com> wrote:
> Works like a charm, fixes another bug alongside (x:dataTables can
> finally be used on tabbed-panes as well!)
> 
> ..and is therefore committed!
> 
> Feedback from anyone?
> 
> Thanks Philipp for bearing through this lengthy process with me, and
> thanks even more for helping out with this very necessary patch!
> 
> regards,
> 
> Martin
> 
> On 5/22/05, Philipp Ahlner <ph...@gmail.com> wrote:
> > Über JS habe ich auch mal kurz nachgedacht, aber da sehe ich zwei Probleme:
> >
> > 1. will man das aktivierte Tab abfragen kann man das nicht mehr, weil
> > es bei einer reinen JS-Lösung kein Model-Update gäbe und wenn doch
> > (also das Umschalten mit einem Request verbunden), dann kann man auf
> > JS gleich verzichten und es so machen, wie bisher.
> >
> > 2. Bei einer reinen JS-Lösung müsste man letztendlich doch einen
> > Request losschicken, weil man die EventListener ja benachrichtigen
> > sollte.
> >
> > Und ausserdem finde JS immer Murks, ich vermeide es gerne, wenn ich
> > kann. Ich hoffe es funzt jetzt und kommt evtl. noch in die M10 rein.
> >
> > Grüße aus Leipzig,
> > Philipp
> >
> > 2005/5/22, Martin Marinschek <ma...@gmail.com>:
> > > Entschuldigung, falsche Formulierung: zusätzlich mit JavaScript machen
> > > (also die Tabs ein/ausblenden nur über JavaScript).
> > >
> > > lg,
> > >
> > > Martin
> > >
> > > On 5/22/05, Martin Marinschek <ma...@gmail.com> wrote:
> > > > Können wir!
> > > >
> > > > dein neuer Vorschlag gefällt mir sehr gut, das ist genau das, was
> > > > schon einmal auf der Mailingliste diskutiert wurde und keiner jemals
> > > > implementiert hat ;) (also eigentlich wollten die das ursprünglich mit
> > > > JavaScript machen, aber es geht natürlich auch mit CSS.
> > > >
> > > > lg,
> > > >
> > > > Martin
> > > >
> > > > On 5/22/05, Philipp Ahlner <ph...@gmail.com> wrote:
> > > > > Hi Martin!
> > > > >
> > > > > Can we speak german outside the ML?
> > > > >
> > > > > 2005/5/22, Philipp Ahlner <ph...@gmail.com>:
> > > > > > Hmm, oh sorry. I see UISelectMany needs a special handling too. The
> > > > > > setting of the submittedValue's need to be more complex. I will check
> > > > > > all javax.faces.component.UI* classes for all exemptions. But I don't
> > > > > > know how I can make this generic for implementation of user
> > > > > > components. Dispatching by UI* classes is not save for user
> > > > > > implementations but if I add the values to the parameterMap the
> > > > > > renderer of each component has to do the job. This will be save for
> > > > > > any component without special handling of individual components. I
> > > > > > have not really a test enviroment at home. I'll submit another
> > > > > > improved patch on next week.
> > > > > > Sorry for that.
> > > > > >
> > > > > > Regards,
> > > > > >
> > > > > > Philipp
> > > > > >
> > > > > > 2005/5/21, Martin Marinschek <ma...@gmail.com>:
> > > > > > > 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 <ph...@gmail.com> 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 <ma...@gmail.com>:
> > > > > > > > > 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 <ma...@gmail.com> wrote:
> > > > > > > > > > ---------- Forwarded message ----------
> > > > > > > > > > From: Martin Marinschek <ma...@gmail.com>
> > > > > > > > > > Date: May 21, 2005 10:32 PM
> > > > > > > > > > Subject: Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong
> > > > > > > > > > validation behavior
> > > > > > > > > > To: Philipp Ahlner <ph...@gmail.com>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > 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 <ph...@gmail.com> 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 <ma...@gmail.com>:
> > > > > > > > > > > > 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 <ph...@gmail.com> 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 <jt...@p00p.org>:
> > > > > > > > > > > > > > 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 <ma...@gmail.com>:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >> 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-
> > > > > > > > > > > > > > >> dev@incubator.apache.org> 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
> > > > > > > > > > > > > > >>>
> > > > > > > > > > > > > > >>>
> > > > > > > > > > > > > > >>>
> > > > > > > > > > > > > > >>
> > > > > > > > > > > > > > >>
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> >
>

Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Enrique Medina <e....@gmail.com>.
Hi Martin,

I was already using the tabbed panel with nested <x:dataTable> tags
without problems apparently.

What has been the bug fixed regarding this issue?

On 5/22/05, Martin Marinschek <ma...@gmail.com> wrote:
> Works like a charm, fixes another bug alongside (x:dataTables can
> finally be used on tabbed-panes as well!)
> 
> ..and is therefore committed!
> 
> Feedback from anyone?
> 
> Thanks Philipp for bearing through this lengthy process with me, and
> thanks even more for helping out with this very necessary patch!
> 
> regards,
> 
> Martin
> 
> On 5/22/05, Philipp Ahlner <ph...@gmail.com> wrote:
> > Über JS habe ich auch mal kurz nachgedacht, aber da sehe ich zwei Probleme:
> >
> > 1. will man das aktivierte Tab abfragen kann man das nicht mehr, weil
> > es bei einer reinen JS-Lösung kein Model-Update gäbe und wenn doch
> > (also das Umschalten mit einem Request verbunden), dann kann man auf
> > JS gleich verzichten und es so machen, wie bisher.
> >
> > 2. Bei einer reinen JS-Lösung müsste man letztendlich doch einen
> > Request losschicken, weil man die EventListener ja benachrichtigen
> > sollte.
> >
> > Und ausserdem finde JS immer Murks, ich vermeide es gerne, wenn ich
> > kann. Ich hoffe es funzt jetzt und kommt evtl. noch in die M10 rein.
> >
> > Grüße aus Leipzig,
> > Philipp
> >
> > 2005/5/22, Martin Marinschek <ma...@gmail.com>:
> > > Entschuldigung, falsche Formulierung: zusätzlich mit JavaScript machen
> > > (also die Tabs ein/ausblenden nur über JavaScript).
> > >
> > > lg,
> > >
> > > Martin
> > >
> > > On 5/22/05, Martin Marinschek <ma...@gmail.com> wrote:
> > > > Können wir!
> > > >
> > > > dein neuer Vorschlag gefällt mir sehr gut, das ist genau das, was
> > > > schon einmal auf der Mailingliste diskutiert wurde und keiner jemals
> > > > implementiert hat ;) (also eigentlich wollten die das ursprünglich mit
> > > > JavaScript machen, aber es geht natürlich auch mit CSS.
> > > >
> > > > lg,
> > > >
> > > > Martin
> > > >
> > > > On 5/22/05, Philipp Ahlner <ph...@gmail.com> wrote:
> > > > > Hi Martin!
> > > > >
> > > > > Can we speak german outside the ML?
> > > > >
> > > > > 2005/5/22, Philipp Ahlner <ph...@gmail.com>:
> > > > > > Hmm, oh sorry. I see UISelectMany needs a special handling too. The
> > > > > > setting of the submittedValue's need to be more complex. I will check
> > > > > > all javax.faces.component.UI* classes for all exemptions. But I don't
> > > > > > know how I can make this generic for implementation of user
> > > > > > components. Dispatching by UI* classes is not save for user
> > > > > > implementations but if I add the values to the parameterMap the
> > > > > > renderer of each component has to do the job. This will be save for
> > > > > > any component without special handling of individual components. I
> > > > > > have not really a test enviroment at home. I'll submit another
> > > > > > improved patch on next week.
> > > > > > Sorry for that.
> > > > > >
> > > > > > Regards,
> > > > > >
> > > > > > Philipp
> > > > > >
> > > > > > 2005/5/21, Martin Marinschek <ma...@gmail.com>:
> > > > > > > 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 <ph...@gmail.com> 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 <ma...@gmail.com>:
> > > > > > > > > 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 <ma...@gmail.com> wrote:
> > > > > > > > > > ---------- Forwarded message ----------
> > > > > > > > > > From: Martin Marinschek <ma...@gmail.com>
> > > > > > > > > > Date: May 21, 2005 10:32 PM
> > > > > > > > > > Subject: Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong
> > > > > > > > > > validation behavior
> > > > > > > > > > To: Philipp Ahlner <ph...@gmail.com>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > 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 <ph...@gmail.com> 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 <ma...@gmail.com>:
> > > > > > > > > > > > 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 <ph...@gmail.com> 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 <jt...@p00p.org>:
> > > > > > > > > > > > > > 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 <ma...@gmail.com>:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >> 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-
> > > > > > > > > > > > > > >> dev@incubator.apache.org> 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
> > > > > > > > > > > > > > >>>
> > > > > > > > > > > > > > >>>
> > > > > > > > > > > > > > >>>
> > > > > > > > > > > > > > >>
> > > > > > > > > > > > > > >>
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> >
>

Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Martin Marinschek <ma...@gmail.com>.
Works like a charm, fixes another bug alongside (x:dataTables can
finally be used on tabbed-panes as well!)

..and is therefore committed!

Feedback from anyone?

Thanks Philipp for bearing through this lengthy process with me, and
thanks even more for helping out with this very necessary patch!

regards,

Martin

On 5/22/05, Philipp Ahlner <ph...@gmail.com> wrote:
> Über JS habe ich auch mal kurz nachgedacht, aber da sehe ich zwei Probleme:
> 
> 1. will man das aktivierte Tab abfragen kann man das nicht mehr, weil
> es bei einer reinen JS-Lösung kein Model-Update gäbe und wenn doch
> (also das Umschalten mit einem Request verbunden), dann kann man auf
> JS gleich verzichten und es so machen, wie bisher.
> 
> 2. Bei einer reinen JS-Lösung müsste man letztendlich doch einen
> Request losschicken, weil man die EventListener ja benachrichtigen
> sollte.
> 
> Und ausserdem finde JS immer Murks, ich vermeide es gerne, wenn ich
> kann. Ich hoffe es funzt jetzt und kommt evtl. noch in die M10 rein.
> 
> Grüße aus Leipzig,
> Philipp
> 
> 2005/5/22, Martin Marinschek <ma...@gmail.com>:
> > Entschuldigung, falsche Formulierung: zusätzlich mit JavaScript machen
> > (also die Tabs ein/ausblenden nur über JavaScript).
> >
> > lg,
> >
> > Martin
> >
> > On 5/22/05, Martin Marinschek <ma...@gmail.com> wrote:
> > > Können wir!
> > >
> > > dein neuer Vorschlag gefällt mir sehr gut, das ist genau das, was
> > > schon einmal auf der Mailingliste diskutiert wurde und keiner jemals
> > > implementiert hat ;) (also eigentlich wollten die das ursprünglich mit
> > > JavaScript machen, aber es geht natürlich auch mit CSS.
> > >
> > > lg,
> > >
> > > Martin
> > >
> > > On 5/22/05, Philipp Ahlner <ph...@gmail.com> wrote:
> > > > Hi Martin!
> > > >
> > > > Can we speak german outside the ML?
> > > >
> > > > 2005/5/22, Philipp Ahlner <ph...@gmail.com>:
> > > > > Hmm, oh sorry. I see UISelectMany needs a special handling too. The
> > > > > setting of the submittedValue's need to be more complex. I will check
> > > > > all javax.faces.component.UI* classes for all exemptions. But I don't
> > > > > know how I can make this generic for implementation of user
> > > > > components. Dispatching by UI* classes is not save for user
> > > > > implementations but if I add the values to the parameterMap the
> > > > > renderer of each component has to do the job. This will be save for
> > > > > any component without special handling of individual components. I
> > > > > have not really a test enviroment at home. I'll submit another
> > > > > improved patch on next week.
> > > > > Sorry for that.
> > > > >
> > > > > Regards,
> > > > >
> > > > > Philipp
> > > > >
> > > > > 2005/5/21, Martin Marinschek <ma...@gmail.com>:
> > > > > > 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 <ph...@gmail.com> 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 <ma...@gmail.com>:
> > > > > > > > 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 <ma...@gmail.com> wrote:
> > > > > > > > > ---------- Forwarded message ----------
> > > > > > > > > From: Martin Marinschek <ma...@gmail.com>
> > > > > > > > > Date: May 21, 2005 10:32 PM
> > > > > > > > > Subject: Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong
> > > > > > > > > validation behavior
> > > > > > > > > To: Philipp Ahlner <ph...@gmail.com>
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > 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 <ph...@gmail.com> 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 <ma...@gmail.com>:
> > > > > > > > > > > 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 <ph...@gmail.com> 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 <jt...@p00p.org>:
> > > > > > > > > > > > > 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 <ma...@gmail.com>:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >> 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-
> > > > > > > > > > > > > >> dev@incubator.apache.org> 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
> > > > > > > > > > > > > >>>
> > > > > > > > > > > > > >>>
> > > > > > > > > > > > > >>>
> > > > > > > > > > > > > >>
> > > > > > > > > > > > > >>
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
> 
>

Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Martin Marinschek <ma...@gmail.com>.
Works like a charm, fixes another bug alongside (x:dataTables can
finally be used on tabbed-panes as well!)

..and is therefore committed!

Feedback from anyone?

Thanks Philipp for bearing through this lengthy process with me, and
thanks even more for helping out with this very necessary patch!

regards,

Martin

On 5/22/05, Philipp Ahlner <ph...@gmail.com> wrote:
> Über JS habe ich auch mal kurz nachgedacht, aber da sehe ich zwei Probleme:
> 
> 1. will man das aktivierte Tab abfragen kann man das nicht mehr, weil
> es bei einer reinen JS-Lösung kein Model-Update gäbe und wenn doch
> (also das Umschalten mit einem Request verbunden), dann kann man auf
> JS gleich verzichten und es so machen, wie bisher.
> 
> 2. Bei einer reinen JS-Lösung müsste man letztendlich doch einen
> Request losschicken, weil man die EventListener ja benachrichtigen
> sollte.
> 
> Und ausserdem finde JS immer Murks, ich vermeide es gerne, wenn ich
> kann. Ich hoffe es funzt jetzt und kommt evtl. noch in die M10 rein.
> 
> Grüße aus Leipzig,
> Philipp
> 
> 2005/5/22, Martin Marinschek <ma...@gmail.com>:
> > Entschuldigung, falsche Formulierung: zusätzlich mit JavaScript machen
> > (also die Tabs ein/ausblenden nur über JavaScript).
> >
> > lg,
> >
> > Martin
> >
> > On 5/22/05, Martin Marinschek <ma...@gmail.com> wrote:
> > > Können wir!
> > >
> > > dein neuer Vorschlag gefällt mir sehr gut, das ist genau das, was
> > > schon einmal auf der Mailingliste diskutiert wurde und keiner jemals
> > > implementiert hat ;) (also eigentlich wollten die das ursprünglich mit
> > > JavaScript machen, aber es geht natürlich auch mit CSS.
> > >
> > > lg,
> > >
> > > Martin
> > >
> > > On 5/22/05, Philipp Ahlner <ph...@gmail.com> wrote:
> > > > Hi Martin!
> > > >
> > > > Can we speak german outside the ML?
> > > >
> > > > 2005/5/22, Philipp Ahlner <ph...@gmail.com>:
> > > > > Hmm, oh sorry. I see UISelectMany needs a special handling too. The
> > > > > setting of the submittedValue's need to be more complex. I will check
> > > > > all javax.faces.component.UI* classes for all exemptions. But I don't
> > > > > know how I can make this generic for implementation of user
> > > > > components. Dispatching by UI* classes is not save for user
> > > > > implementations but if I add the values to the parameterMap the
> > > > > renderer of each component has to do the job. This will be save for
> > > > > any component without special handling of individual components. I
> > > > > have not really a test enviroment at home. I'll submit another
> > > > > improved patch on next week.
> > > > > Sorry for that.
> > > > >
> > > > > Regards,
> > > > >
> > > > > Philipp
> > > > >
> > > > > 2005/5/21, Martin Marinschek <ma...@gmail.com>:
> > > > > > 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 <ph...@gmail.com> 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 <ma...@gmail.com>:
> > > > > > > > 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 <ma...@gmail.com> wrote:
> > > > > > > > > ---------- Forwarded message ----------
> > > > > > > > > From: Martin Marinschek <ma...@gmail.com>
> > > > > > > > > Date: May 21, 2005 10:32 PM
> > > > > > > > > Subject: Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong
> > > > > > > > > validation behavior
> > > > > > > > > To: Philipp Ahlner <ph...@gmail.com>
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > 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 <ph...@gmail.com> 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 <ma...@gmail.com>:
> > > > > > > > > > > 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 <ph...@gmail.com> 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 <jt...@p00p.org>:
> > > > > > > > > > > > > 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 <ma...@gmail.com>:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >> 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-
> > > > > > > > > > > > > >> dev@incubator.apache.org> 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
> > > > > > > > > > > > > >>>
> > > > > > > > > > > > > >>>
> > > > > > > > > > > > > >>>
> > > > > > > > > > > > > >>
> > > > > > > > > > > > > >>
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
> 
>

Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Martin Marinschek <ma...@gmail.com>.
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 <ph...@gmail.com> 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 <ma...@gmail.com>:
> > 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 <ma...@gmail.com> wrote:
> > > ---------- Forwarded message ----------
> > > From: Martin Marinschek <ma...@gmail.com>
> > > Date: May 21, 2005 10:32 PM
> > > Subject: Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong
> > > validation behavior
> > > To: Philipp Ahlner <ph...@gmail.com>
> > >
> > >
> > > 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 <ph...@gmail.com> 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 <ma...@gmail.com>:
> > > > > 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 <ph...@gmail.com> 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 <jt...@p00p.org>:
> > > > > > > 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 <ma...@gmail.com>:
> > > > > > > >
> > > > > > > >> 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-
> > > > > > > >> dev@incubator.apache.org> 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
> > > > > > > >>>
> > > > > > > >>>
> > > > > > > >>>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
> 
>

Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Martin Marinschek <ma...@gmail.com>.
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 <ma...@gmail.com> wrote:
> ---------- Forwarded message ----------
> From: Martin Marinschek <ma...@gmail.com>
> Date: May 21, 2005 10:32 PM
> Subject: Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong
> validation behavior
> To: Philipp Ahlner <ph...@gmail.com>
> 
> 
> 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 <ph...@gmail.com> 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 <ma...@gmail.com>:
> > > 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 <ph...@gmail.com> 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 <jt...@p00p.org>:
> > > > > 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 <ma...@gmail.com>:
> > > > > >
> > > > > >> 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-
> > > > > >> dev@incubator.apache.org> 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
> > > > > >>>
> > > > > >>>
> > > > > >>>
> > > > > >>
> > > > > >>
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> >
>

Fwd: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Martin Marinschek <ma...@gmail.com>.
---------- Forwarded message ----------
From: Martin Marinschek <ma...@gmail.com>
Date: May 21, 2005 10:32 PM
Subject: Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong
validation behavior
To: Philipp Ahlner <ph...@gmail.com>


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 <ph...@gmail.com> 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 <ma...@gmail.com>:
> > 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 <ph...@gmail.com> 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 <jt...@p00p.org>:
> > > > 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 <ma...@gmail.com>:
> > > > >
> > > > >> 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-
> > > > >> dev@incubator.apache.org> 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
> > > > >>>
> > > > >>>
> > > > >>>
> > > > >>
> > > > >>
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> >
>
>

Fwd: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Martin Marinschek <ma...@gmail.com>.
---------- Forwarded message ----------
From: Martin Marinschek <ma...@gmail.com>
Date: May 21, 2005 10:48 PM
Subject: Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong
validation behavior
To: Philipp Ahlner <ph...@gmail.com>


Another thing... what about facets? do we need your behaviour there as
well? with getChildren() you iterate through the children only and not
through the facets - are facets in the tabbedPanel only used for the
whole panel or also on each page?

Sorry for asking that many questions, but I have never used the
tabbed-panel in one of my projects, so I don't know much about the
inner workings and don't want to damage anything.

regards,

Martin

On 5/21/05, Martin Marinschek <ma...@gmail.com> wrote:
> 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 <ph...@gmail.com> 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 <ma...@gmail.com>:
> > > 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 <ph...@gmail.com> 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 <jt...@p00p.org>:
> > > > > 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 <ma...@gmail.com>:
> > > > > >
> > > > > >> 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-
> > > > > >> dev@incubator.apache.org> 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
> > > > > >>>
> > > > > >>>
> > > > > >>>
> > > > > >>
> > > > > >>
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> >
>

Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Martin Marinschek <ma...@gmail.com>.
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 <ph...@gmail.com> 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 <jt...@p00p.org>:
> > 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 <ma...@gmail.com>:
> > >
> > >> 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-
> > >> dev@incubator.apache.org> 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
> > >>>
> > >>>
> > >>>
> > >>
> > >>
> > >
> > >
> > >
> >
> >
>

Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Philipp Ahlner <ph...@gmail.com>.
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 <jt...@p00p.org>:
> 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 <ma...@gmail.com>:
> >
> >> 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-
> >> dev@incubator.apache.org> 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
> >>>
> >>>
> >>>
> >>
> >>
> >
> >
> >
> 
>

Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Jon Travis <jt...@p00p.org>.
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 <ma...@gmail.com>:
>
>> 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- 
>> dev@incubator.apache.org> 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
>>>
>>>
>>>
>>
>>
>
>
>



Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Philipp Ahlner <ph...@gmail.com>.
2005/5/20, Martin Marinschek <ma...@gmail.com>:
> 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) <my...@incubator.apache.org> 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
> >
> >
>

Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Martin Marinschek <ma...@gmail.com>.
Now what happens when a component is not rendered at all and returns a
null value - you validate it anyways?

Shouldn't only those components who submit a value be validated?

regards,

Martin

On 5/20/05, Philipp Ahlner (JIRA) <my...@incubator.apache.org> 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
> 
>

Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Martin Marinschek <ma...@gmail.com>.
I like that one - I will try it out and commit it if it works.

regards,

Martin

On 5/22/05, Philipp Ahlner (JIRA) <my...@incubator.apache.org> wrote:
>      [ http://issues.apache.org/jira/browse/MYFACES-214?page=comments#action_65954 ]
> 
> Philipp Ahlner commented on MYFACES-214:
> ----------------------------------------
> 
> Since many components (like HtmlSelectBooleanCheckbox) expects a boolean value as submitted value (only the decode-method of each renderer knows what type as submittedValue has to set), I'm tending to discard the idea to "fake" submittedValue. I can now provide a patch which hides the not-selected tabs with a <div style="display:none">-tag. The disadvantage of this solution is that the content of each tab is transferred to the browser, but this solution never breaks the jsf-spec.
> Please forget all patches I've submitted before :-)
> 
> 
> I've changed the HtmlTabbedPaneRenderer.writeTabCell() method. If a tab is hidden, the components are enclosed in a div tag.
> 
> protected void writeTabCell(ResponseWriter writer, FacesContext facesContext, HtmlPanelTabbedPane tabbedPane,
>             int tabCount, int selectedIndex) throws IOException {
>         HtmlRendererUtils.writePrettyLineSeparator(facesContext);
>         HtmlRendererUtils.writePrettyIndent(facesContext);
>         writer.startElement(HTML.TD_ELEM, tabbedPane);
>         writer.writeAttribute(HTML.COLSPAN_ATTR, Integer.toString(tabCount + 1), null);
>         writer.writeAttribute(HTML.STYLE_ATTR, TAB_CELL_STYLE + "background-color:" + tabbedPane.getBgcolor(), null);
>         HtmlRendererUtils.renderHTMLAttribute(writer, tabbedPane, "tabContentStyleClass", HTML.STYLE_CLASS_ATTR);
> 
>         int tabIdx = 0;
>         List children = tabbedPane.getChildren();
>         for (int i = 0, len = children.size(); i < len; i++) {
>             UIComponent child = getUIComponent((UIComponent) children.get(i));
>             if (child instanceof HtmlPanelTab) {
>                 // the inactive tabs are hidden with a div-tag
>                 if (tabIdx != selectedIndex) {
>                     writer.startElement(HTML.DIV_ELEM, tabbedPane);
>                     writer.writeAttribute(HTML.STYLE_ATTR, "display:none", null);
>                     RendererUtils.renderChild(facesContext, child);
>                     writer.endElement(HTML.DIV_ELEM);
>                 }
>                 else
>                 {
>                     RendererUtils.renderChild(facesContext, child);
>                 }
> 
>                 tabIdx++;
>             } else {
>                 RendererUtils.renderChild(facesContext, child);
>             }
>         }
> 
>         writer.endElement(HTML.TD_ELEM);
>     }
> 
> 
> A second change is necessary (we cannot only decode the visible tab, all components are correctly rendered and must be decoded) in HtmlPanelTabbedPane.processDecodes:
> 
> 
> public void processDecodes(javax.faces.context.FacesContext context)
>     {
>         if (context == null) throw new NullPointerException("context");
>         decode(context);
> 
>         int tabIdx = 0;
>         int selectedIndex = getSelectedIndex();
> 
>         Iterator it = getFacetsAndChildren();
> 
>         while (it.hasNext())
>         {
>             UIComponent childOrFacet = getUIComponent((UIComponent) it.next());
>             childOrFacet.processDecodes(context);
>         }
>     }
> 
> I've tested my solution with the examples and Firefox 1.0.4 (LinuX). I'll test the solution with a IE in the next days.
> I've changed the tabbedPane.jsp in the examples at the 3rd pane as follows to test my solution:
> 
> from:
> <h:inputText id="inp3"/>
> to:
> <h:inputText id="inp3" required="true"/>
> 
> I would propose this change in the examples for tests in the future.
> 
> 
> > 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
> 
>

[jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by "Philipp Ahlner (JIRA)" <my...@incubator.apache.org>.
     [ 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


[jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by "Manfred Klug (JIRA)" <my...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/MYFACES-214?page=comments#action_65385 ]
     
Manfred Klug commented on MYFACES-214:
--------------------------------------

>  The rendered-property of HtmlPanelTab is true
Yes, my fault :(

But even then, your patch is invalid. The API specification states that there is
no validation if the submittedValue property is null

> 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


Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Philipp Ahlner <ph...@gmail.com>.
Hi Grant!

Tahnks for your answer. My patch was for rc3 and not for trunk. Sorry,
I havent seen that the lines

if (submittedValue != null && submittedValue instanceof String &&
((String) submittedValue).length()==0)
{
    submittedValue = null;
}

are already obsolet in trunk. These lines are not really my problem.
My problem is following line.

if (submittedValue == null) return;

I think this line should be removed to fix this bug, but UIInput is a
very common base-class and I don't have the overview over all
components - so I've bellyache.

Philipp


2005/5/12, Grant Smith <gr...@marathon-man.com>:
>  Hi Phillip,
>  
>  Your patch basically reverses a patch made as a suggestion to MYFACES-187.
> Could you test to see if your patch produces the same problem that
> MYFACES-187 describes ? I do see a small difference between your code and
> the original code, so it's possible that your patch fixes both, but we need
> to be sure :)
>  
>  Thanks,
>  Grant.
>  
>  Philipp Ahlner (JIRA) wrote: 
>  [
> http://issues.apache.org/jira/browse/MYFACES-214?page=comments#action_65117
> ]
>  
> Philipp Ahlner commented on MYFACES-214:
> ----------------------------------------
> 
> After a nightly debugging session, I think I know where the problem is. I
> applied my patch and it's working for me. I'll try to explain (in my poor
> english) the problem and the solution.
> 
> The origin problem is not the tabbedpane-component but rather a single line
> in javax.faces.component.UIInput
> 
> The solution:
> In 0.9rc3 in line 284:
> 
> if (submittedValue == null) return;
> 
> the validation stops if the submitted value is null. I think this should
> prevent a NPE on the line below. If removed the return statement and
> modified the line below as followed:
> 
> if (submittedValue != null && submittedValue instanceof String && ((String)
> submittedValue).length()==0)
> {
>  submittedValue = null;
> }
> 
> This also prevents a NPE but the validation is continued with a null as
> submittedValue. UIInput is a base-class of all input elements and this patch
> should made all ui-components work correctly in tabbed panes.
> 
> Let me now explain, why its a problem to stop validation on a null value:
> 
> - If a UIInput-child-element is in a hidden tabbed-pane the submittedValue
> is null and such a element is never validated.
> - If a hidden tab is activated and the HtmlInput is empty (for ex) the
> decode() method of the renderer (HtmlTextRendererBase) sets a empty string
> instead of null to submittedValue. The field will now validated in all cases
> regarding the tab is visible or not.
> 
> That's he reason why a field is not validated until the tab is at least one
> time activated. 
> My patch validates all UIInputs regardless of the value in the
> submittedValue var.
> 
>  
>  
>  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
>  
>  
>  
>

Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Grant Smith <gr...@marathon-man.com>.
Hi Phillip,

Your patch basically reverses a patch made as a suggestion to 
MYFACES-187. Could you test to see if your patch produces the same 
problem that MYFACES-187 describes ? I do see a small difference between 
your code and the original code, so it's possible that your patch fixes 
both, but we need to be sure :)

Thanks,
Grant.

Philipp Ahlner (JIRA) wrote:

>     [ http://issues.apache.org/jira/browse/MYFACES-214?page=comments#action_65117 ]
>     
>Philipp Ahlner commented on MYFACES-214:
>----------------------------------------
>
>After a nightly debugging session, I think I know where the problem is. I applied my patch and it's working for me. I'll try to explain (in my poor english) the problem and the solution.
>
>The origin problem is not the tabbedpane-component but rather a single line in javax.faces.component.UIInput
>
>The solution:
>In 0.9rc3 in line 284:
>
>if (submittedValue == null) return;
>
>the validation stops if the submitted value is null. I think this should prevent a NPE on the line below. If removed the return statement and modified the line below as followed:
>
>if (submittedValue != null && submittedValue instanceof String && ((String) submittedValue).length()==0)
>{
>    submittedValue = null;
>}
>
>This also prevents a NPE but the validation is continued with a null as submittedValue. UIInput is a base-class of all input elements and this patch should made all ui-components work correctly in tabbed panes.
>
>Let me now explain, why its a problem to stop validation on a null value:
>
>- If a UIInput-child-element is in a hidden tabbed-pane the submittedValue is null and such a element is never validated.
>- If a hidden tab is activated and the HtmlInput is empty (for ex) the decode() method of the renderer (HtmlTextRendererBase) sets a empty string instead of null to submittedValue. The field will now validated in all cases regarding the tab is visible or not.
>
>That's he reason why a field is not validated until the tab is at least one time activated. 
>My patch validates all UIInputs regardless of the value in the submittedValue var.
>
>  
>
>>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
>>    
>>
>
>  
>


[jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by "Philipp Ahlner (JIRA)" <my...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/MYFACES-214?page=comments#action_65117 ]
     
Philipp Ahlner commented on MYFACES-214:
----------------------------------------

After a nightly debugging session, I think I know where the problem is. I applied my patch and it's working for me. I'll try to explain (in my poor english) the problem and the solution.

The origin problem is not the tabbedpane-component but rather a single line in javax.faces.component.UIInput

The solution:
In 0.9rc3 in line 284:

if (submittedValue == null) return;

the validation stops if the submitted value is null. I think this should prevent a NPE on the line below. If removed the return statement and modified the line below as followed:

if (submittedValue != null && submittedValue instanceof String && ((String) submittedValue).length()==0)
{
    submittedValue = null;
}

This also prevents a NPE but the validation is continued with a null as submittedValue. UIInput is a base-class of all input elements and this patch should made all ui-components work correctly in tabbed panes.

Let me now explain, why its a problem to stop validation on a null value:

- If a UIInput-child-element is in a hidden tabbed-pane the submittedValue is null and such a element is never validated.
- If a hidden tab is activated and the HtmlInput is empty (for ex) the decode() method of the renderer (HtmlTextRendererBase) sets a empty string instead of null to submittedValue. The field will now validated in all cases regarding the tab is visible or not.

That's he reason why a field is not validated until the tab is at least one time activated. 
My patch validates all UIInputs regardless of the value in the submittedValue var.

> 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


[jira] Closed: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by "Martin Marinschek (JIRA)" <my...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/MYFACES-214?page=all ]
     
Martin Marinschek closed MYFACES-214:
-------------------------------------

      Assign To: Martin Marinschek
     Resolution: Fixed
    Fix Version: Nightly Build

Fix by Philipp Ahlner. Thanks very much!

> 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
>     Assignee: Martin Marinschek
>      Fix For: Nightly Build

>
> 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


Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Jon Travis <jt...@p00p.org>.
No, it's not a problem with the tabbed pane -- just the
next thing on my list of problems I'm seeing with MyFaces.

Apparently someone already reported this new issue.

Thanks again for the pane fixes -- I'll let you know if I
find any problems.

-- Jon


On May 25, 2005, at 1:07 PM, Philipp Ahlner wrote:

> Hi Jon!
>
> Throws a custom converter the stacktrace? Can you provide a stack  
> trace?
> I can't imagine a association with the tabbedpanes but I will check  
> this.
>
> 2005/5/25, Jon Travis <jt...@p00p.org>:
>
>> I've got it working after moving forms around.
>>
>> Onto the next problem, which is why the SelectManyListboxes
>> are having a submitted value of "" and throwing converter
>> exceptions...
>>
>> -- Jon
>>
>>
>> On May 23, 2005, at 10:50 PM, Martin Marinschek wrote:
>>
>>
>>> Strange... I tested with the MyFaces examples, and they worked as
>>> expected.
>>>
>>> Did you give the examples a test-ride, do they seem broken as well?
>>>
>>> regards,
>>>
>>> Martin
>>>
>>> On 5/24/05, Jon Travis <jt...@p00p.org> wrote:
>>>
>>>
>>>> Updated to HEAD to get this patch, but now nearly all my tab
>>>> functionality is broken.  I'll have more time to dig into
>>>> this later (though I may just revert my update and keep
>>>> going for a little while.)  getAsString in my converter
>>>> is called with "", for instance, so I'm getting things
>>>> like ClassCast exceptions, etc.
>>>>
>>>> -- Jon
>>>>
>>>>
>>>> On May 22, 2005, at 6:49 AM, Philipp Ahlner (JIRA) wrote:
>>>>
>>>>
>>>>
>>>>>      [ http://issues.apache.org/jira/browse/MYFACES-214?
>>>>> page=comments#action_65954 ]
>>>>>
>>>>> Philipp Ahlner commented on MYFACES-214:
>>>>> ----------------------------------------
>>>>>
>>>>> Since many components (like HtmlSelectBooleanCheckbox) expects a
>>>>> boolean value as submitted value (only the decode-method of each
>>>>> renderer knows what type as submittedValue has to set), I'm  
>>>>> tending
>>>>> to discard the idea to "fake" submittedValue. I can now provide a
>>>>> patch which hides the not-selected tabs with a <div
>>>>> style="display:none">-tag. The disadvantage of this solution is
>>>>> that the content of each tab is transferred to the browser, but
>>>>> this solution never breaks the jsf-spec.
>>>>> Please forget all patches I've submitted before :-)
>>>>>
>>>>>
>>>>> I've changed the HtmlTabbedPaneRenderer.writeTabCell() method.  
>>>>> If a
>>>>> tab is hidden, the components are enclosed in a div tag.
>>>>>
>>>>> protected void writeTabCell(ResponseWriter writer, FacesContext
>>>>> facesContext, HtmlPanelTabbedPane tabbedPane,
>>>>>             int tabCount, int selectedIndex) throws IOException {
>>>>>         HtmlRendererUtils.writePrettyLineSeparator(facesContext);
>>>>>         HtmlRendererUtils.writePrettyIndent(facesContext);
>>>>>         writer.startElement(HTML.TD_ELEM, tabbedPane);
>>>>>         writer.writeAttribute(HTML.COLSPAN_ATTR, Integer.toString
>>>>> (tabCount + 1), null);
>>>>>         writer.writeAttribute(HTML.STYLE_ATTR, TAB_CELL_STYLE +
>>>>> "background-color:" + tabbedPane.getBgcolor(), null);
>>>>>         HtmlRendererUtils.renderHTMLAttribute(writer, tabbedPane,
>>>>> "tabContentStyleClass", HTML.STYLE_CLASS_ATTR);
>>>>>
>>>>>         int tabIdx = 0;
>>>>>         List children = tabbedPane.getChildren();
>>>>>         for (int i = 0, len = children.size(); i < len; i++) {
>>>>>             UIComponent child = getUIComponent((UIComponent)
>>>>> children.get(i));
>>>>>             if (child instanceof HtmlPanelTab) {
>>>>>                 // the inactive tabs are hidden with a div-tag
>>>>>                 if (tabIdx != selectedIndex) {
>>>>>                     writer.startElement(HTML.DIV_ELEM,  
>>>>> tabbedPane);
>>>>>                     writer.writeAttribute(HTML.STYLE_ATTR,
>>>>> "display:none", null);
>>>>>                     RendererUtils.renderChild(facesContext,  
>>>>> child);
>>>>>                     writer.endElement(HTML.DIV_ELEM);
>>>>>                 }
>>>>>                 else
>>>>>                 {
>>>>>                     RendererUtils.renderChild(facesContext,  
>>>>> child);
>>>>>                 }
>>>>>
>>>>>                 tabIdx++;
>>>>>             } else {
>>>>>                 RendererUtils.renderChild(facesContext, child);
>>>>>             }
>>>>>         }
>>>>>
>>>>>         writer.endElement(HTML.TD_ELEM);
>>>>>     }
>>>>>
>>>>>
>>>>> A second change is necessary (we cannot only decode the visible
>>>>> tab, all components are correctly rendered and must be decoded) in
>>>>> HtmlPanelTabbedPane.processDecodes:
>>>>>
>>>>>
>>>>> public void processDecodes(javax.faces.context.FacesContext  
>>>>> context)
>>>>>     {
>>>>>         if (context == null) throw new NullPointerException
>>>>> ("context");
>>>>>         decode(context);
>>>>>
>>>>>         int tabIdx = 0;
>>>>>         int selectedIndex = getSelectedIndex();
>>>>>
>>>>>         Iterator it = getFacetsAndChildren();
>>>>>
>>>>>         while (it.hasNext())
>>>>>         {
>>>>>             UIComponent childOrFacet = getUIComponent 
>>>>> ((UIComponent)
>>>>> it.next());
>>>>>             childOrFacet.processDecodes(context);
>>>>>         }
>>>>>     }
>>>>>
>>>>> I've tested my solution with the examples and Firefox 1.0.4
>>>>> (LinuX). I'll test the solution with a IE in the next days.
>>>>> I've changed the tabbedPane.jsp in the examples at the 3rd pane as
>>>>> follows to test my solution:
>>>>>
>>>>> from:
>>>>> <h:inputText id="inp3"/>
>>>>> to:
>>>>> <h:inputText id="inp3" required="true"/>
>>>>>
>>>>> I would propose this change in the examples for tests in the  
>>>>> future.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> 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
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>


Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Philipp Ahlner <ph...@gmail.com>.
Hi Jon!

Throws a custom converter the stacktrace? Can you provide a stack trace?
I can't imagine a association with the tabbedpanes but I will check this.

2005/5/25, Jon Travis <jt...@p00p.org>:
> I've got it working after moving forms around.
> 
> Onto the next problem, which is why the SelectManyListboxes
> are having a submitted value of "" and throwing converter
> exceptions...
> 
> -- Jon
> 
> 
> On May 23, 2005, at 10:50 PM, Martin Marinschek wrote:
> 
> > Strange... I tested with the MyFaces examples, and they worked as
> > expected.
> >
> > Did you give the examples a test-ride, do they seem broken as well?
> >
> > regards,
> >
> > Martin
> >
> > On 5/24/05, Jon Travis <jt...@p00p.org> wrote:
> >
> >> Updated to HEAD to get this patch, but now nearly all my tab
> >> functionality is broken.  I'll have more time to dig into
> >> this later (though I may just revert my update and keep
> >> going for a little while.)  getAsString in my converter
> >> is called with "", for instance, so I'm getting things
> >> like ClassCast exceptions, etc.
> >>
> >> -- Jon
> >>
> >>
> >> On May 22, 2005, at 6:49 AM, Philipp Ahlner (JIRA) wrote:
> >>
> >>
> >>>      [ http://issues.apache.org/jira/browse/MYFACES-214?
> >>> page=comments#action_65954 ]
> >>>
> >>> Philipp Ahlner commented on MYFACES-214:
> >>> ----------------------------------------
> >>>
> >>> Since many components (like HtmlSelectBooleanCheckbox) expects a
> >>> boolean value as submitted value (only the decode-method of each
> >>> renderer knows what type as submittedValue has to set), I'm tending
> >>> to discard the idea to "fake" submittedValue. I can now provide a
> >>> patch which hides the not-selected tabs with a <div
> >>> style="display:none">-tag. The disadvantage of this solution is
> >>> that the content of each tab is transferred to the browser, but
> >>> this solution never breaks the jsf-spec.
> >>> Please forget all patches I've submitted before :-)
> >>>
> >>>
> >>> I've changed the HtmlTabbedPaneRenderer.writeTabCell() method. If a
> >>> tab is hidden, the components are enclosed in a div tag.
> >>>
> >>> protected void writeTabCell(ResponseWriter writer, FacesContext
> >>> facesContext, HtmlPanelTabbedPane tabbedPane,
> >>>             int tabCount, int selectedIndex) throws IOException {
> >>>         HtmlRendererUtils.writePrettyLineSeparator(facesContext);
> >>>         HtmlRendererUtils.writePrettyIndent(facesContext);
> >>>         writer.startElement(HTML.TD_ELEM, tabbedPane);
> >>>         writer.writeAttribute(HTML.COLSPAN_ATTR, Integer.toString
> >>> (tabCount + 1), null);
> >>>         writer.writeAttribute(HTML.STYLE_ATTR, TAB_CELL_STYLE +
> >>> "background-color:" + tabbedPane.getBgcolor(), null);
> >>>         HtmlRendererUtils.renderHTMLAttribute(writer, tabbedPane,
> >>> "tabContentStyleClass", HTML.STYLE_CLASS_ATTR);
> >>>
> >>>         int tabIdx = 0;
> >>>         List children = tabbedPane.getChildren();
> >>>         for (int i = 0, len = children.size(); i < len; i++) {
> >>>             UIComponent child = getUIComponent((UIComponent)
> >>> children.get(i));
> >>>             if (child instanceof HtmlPanelTab) {
> >>>                 // the inactive tabs are hidden with a div-tag
> >>>                 if (tabIdx != selectedIndex) {
> >>>                     writer.startElement(HTML.DIV_ELEM, tabbedPane);
> >>>                     writer.writeAttribute(HTML.STYLE_ATTR,
> >>> "display:none", null);
> >>>                     RendererUtils.renderChild(facesContext, child);
> >>>                     writer.endElement(HTML.DIV_ELEM);
> >>>                 }
> >>>                 else
> >>>                 {
> >>>                     RendererUtils.renderChild(facesContext, child);
> >>>                 }
> >>>
> >>>                 tabIdx++;
> >>>             } else {
> >>>                 RendererUtils.renderChild(facesContext, child);
> >>>             }
> >>>         }
> >>>
> >>>         writer.endElement(HTML.TD_ELEM);
> >>>     }
> >>>
> >>>
> >>> A second change is necessary (we cannot only decode the visible
> >>> tab, all components are correctly rendered and must be decoded) in
> >>> HtmlPanelTabbedPane.processDecodes:
> >>>
> >>>
> >>> public void processDecodes(javax.faces.context.FacesContext context)
> >>>     {
> >>>         if (context == null) throw new NullPointerException
> >>> ("context");
> >>>         decode(context);
> >>>
> >>>         int tabIdx = 0;
> >>>         int selectedIndex = getSelectedIndex();
> >>>
> >>>         Iterator it = getFacetsAndChildren();
> >>>
> >>>         while (it.hasNext())
> >>>         {
> >>>             UIComponent childOrFacet = getUIComponent((UIComponent)
> >>> it.next());
> >>>             childOrFacet.processDecodes(context);
> >>>         }
> >>>     }
> >>>
> >>> I've tested my solution with the examples and Firefox 1.0.4
> >>> (LinuX). I'll test the solution with a IE in the next days.
> >>> I've changed the tabbedPane.jsp in the examples at the 3rd pane as
> >>> follows to test my solution:
> >>>
> >>> from:
> >>> <h:inputText id="inp3"/>
> >>> to:
> >>> <h:inputText id="inp3" required="true"/>
> >>>
> >>> I would propose this change in the examples for tests in the future.
> >>>
> >>>
> >>>
> >>>
> >>>> 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
> >>>
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >>
> >
> >
> >
> 
>

Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Jon Travis <jt...@p00p.org>.
I've got it working after moving forms around.

Onto the next problem, which is why the SelectManyListboxes
are having a submitted value of "" and throwing converter
exceptions...

-- Jon


On May 23, 2005, at 10:50 PM, Martin Marinschek wrote:

> Strange... I tested with the MyFaces examples, and they worked as  
> expected.
>
> Did you give the examples a test-ride, do they seem broken as well?
>
> regards,
>
> Martin
>
> On 5/24/05, Jon Travis <jt...@p00p.org> wrote:
>
>> Updated to HEAD to get this patch, but now nearly all my tab
>> functionality is broken.  I'll have more time to dig into
>> this later (though I may just revert my update and keep
>> going for a little while.)  getAsString in my converter
>> is called with "", for instance, so I'm getting things
>> like ClassCast exceptions, etc.
>>
>> -- Jon
>>
>>
>> On May 22, 2005, at 6:49 AM, Philipp Ahlner (JIRA) wrote:
>>
>>
>>>      [ http://issues.apache.org/jira/browse/MYFACES-214?
>>> page=comments#action_65954 ]
>>>
>>> Philipp Ahlner commented on MYFACES-214:
>>> ----------------------------------------
>>>
>>> Since many components (like HtmlSelectBooleanCheckbox) expects a
>>> boolean value as submitted value (only the decode-method of each
>>> renderer knows what type as submittedValue has to set), I'm tending
>>> to discard the idea to "fake" submittedValue. I can now provide a
>>> patch which hides the not-selected tabs with a <div
>>> style="display:none">-tag. The disadvantage of this solution is
>>> that the content of each tab is transferred to the browser, but
>>> this solution never breaks the jsf-spec.
>>> Please forget all patches I've submitted before :-)
>>>
>>>
>>> I've changed the HtmlTabbedPaneRenderer.writeTabCell() method. If a
>>> tab is hidden, the components are enclosed in a div tag.
>>>
>>> protected void writeTabCell(ResponseWriter writer, FacesContext
>>> facesContext, HtmlPanelTabbedPane tabbedPane,
>>>             int tabCount, int selectedIndex) throws IOException {
>>>         HtmlRendererUtils.writePrettyLineSeparator(facesContext);
>>>         HtmlRendererUtils.writePrettyIndent(facesContext);
>>>         writer.startElement(HTML.TD_ELEM, tabbedPane);
>>>         writer.writeAttribute(HTML.COLSPAN_ATTR, Integer.toString
>>> (tabCount + 1), null);
>>>         writer.writeAttribute(HTML.STYLE_ATTR, TAB_CELL_STYLE +
>>> "background-color:" + tabbedPane.getBgcolor(), null);
>>>         HtmlRendererUtils.renderHTMLAttribute(writer, tabbedPane,
>>> "tabContentStyleClass", HTML.STYLE_CLASS_ATTR);
>>>
>>>         int tabIdx = 0;
>>>         List children = tabbedPane.getChildren();
>>>         for (int i = 0, len = children.size(); i < len; i++) {
>>>             UIComponent child = getUIComponent((UIComponent)
>>> children.get(i));
>>>             if (child instanceof HtmlPanelTab) {
>>>                 // the inactive tabs are hidden with a div-tag
>>>                 if (tabIdx != selectedIndex) {
>>>                     writer.startElement(HTML.DIV_ELEM, tabbedPane);
>>>                     writer.writeAttribute(HTML.STYLE_ATTR,
>>> "display:none", null);
>>>                     RendererUtils.renderChild(facesContext, child);
>>>                     writer.endElement(HTML.DIV_ELEM);
>>>                 }
>>>                 else
>>>                 {
>>>                     RendererUtils.renderChild(facesContext, child);
>>>                 }
>>>
>>>                 tabIdx++;
>>>             } else {
>>>                 RendererUtils.renderChild(facesContext, child);
>>>             }
>>>         }
>>>
>>>         writer.endElement(HTML.TD_ELEM);
>>>     }
>>>
>>>
>>> A second change is necessary (we cannot only decode the visible
>>> tab, all components are correctly rendered and must be decoded) in
>>> HtmlPanelTabbedPane.processDecodes:
>>>
>>>
>>> public void processDecodes(javax.faces.context.FacesContext context)
>>>     {
>>>         if (context == null) throw new NullPointerException
>>> ("context");
>>>         decode(context);
>>>
>>>         int tabIdx = 0;
>>>         int selectedIndex = getSelectedIndex();
>>>
>>>         Iterator it = getFacetsAndChildren();
>>>
>>>         while (it.hasNext())
>>>         {
>>>             UIComponent childOrFacet = getUIComponent((UIComponent)
>>> it.next());
>>>             childOrFacet.processDecodes(context);
>>>         }
>>>     }
>>>
>>> I've tested my solution with the examples and Firefox 1.0.4
>>> (LinuX). I'll test the solution with a IE in the next days.
>>> I've changed the tabbedPane.jsp in the examples at the 3rd pane as
>>> follows to test my solution:
>>>
>>> from:
>>> <h:inputText id="inp3"/>
>>> to:
>>> <h:inputText id="inp3" required="true"/>
>>>
>>> I would propose this change in the examples for tests in the future.
>>>
>>>
>>>
>>>
>>>> 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
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>


Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Martin Marinschek <ma...@gmail.com>.
Strange... I tested with the MyFaces examples, and they worked as expected.

Did you give the examples a test-ride, do they seem broken as well?

regards,

Martin

On 5/24/05, Jon Travis <jt...@p00p.org> wrote:
> Updated to HEAD to get this patch, but now nearly all my tab
> functionality is broken.  I'll have more time to dig into
> this later (though I may just revert my update and keep
> going for a little while.)  getAsString in my converter
> is called with "", for instance, so I'm getting things
> like ClassCast exceptions, etc.
> 
> -- Jon
> 
> 
> On May 22, 2005, at 6:49 AM, Philipp Ahlner (JIRA) wrote:
> 
> >      [ http://issues.apache.org/jira/browse/MYFACES-214?
> > page=comments#action_65954 ]
> >
> > Philipp Ahlner commented on MYFACES-214:
> > ----------------------------------------
> >
> > Since many components (like HtmlSelectBooleanCheckbox) expects a
> > boolean value as submitted value (only the decode-method of each
> > renderer knows what type as submittedValue has to set), I'm tending
> > to discard the idea to "fake" submittedValue. I can now provide a
> > patch which hides the not-selected tabs with a <div
> > style="display:none">-tag. The disadvantage of this solution is
> > that the content of each tab is transferred to the browser, but
> > this solution never breaks the jsf-spec.
> > Please forget all patches I've submitted before :-)
> >
> >
> > I've changed the HtmlTabbedPaneRenderer.writeTabCell() method. If a
> > tab is hidden, the components are enclosed in a div tag.
> >
> > protected void writeTabCell(ResponseWriter writer, FacesContext
> > facesContext, HtmlPanelTabbedPane tabbedPane,
> >             int tabCount, int selectedIndex) throws IOException {
> >         HtmlRendererUtils.writePrettyLineSeparator(facesContext);
> >         HtmlRendererUtils.writePrettyIndent(facesContext);
> >         writer.startElement(HTML.TD_ELEM, tabbedPane);
> >         writer.writeAttribute(HTML.COLSPAN_ATTR, Integer.toString
> > (tabCount + 1), null);
> >         writer.writeAttribute(HTML.STYLE_ATTR, TAB_CELL_STYLE +
> > "background-color:" + tabbedPane.getBgcolor(), null);
> >         HtmlRendererUtils.renderHTMLAttribute(writer, tabbedPane,
> > "tabContentStyleClass", HTML.STYLE_CLASS_ATTR);
> >
> >         int tabIdx = 0;
> >         List children = tabbedPane.getChildren();
> >         for (int i = 0, len = children.size(); i < len; i++) {
> >             UIComponent child = getUIComponent((UIComponent)
> > children.get(i));
> >             if (child instanceof HtmlPanelTab) {
> >                 // the inactive tabs are hidden with a div-tag
> >                 if (tabIdx != selectedIndex) {
> >                     writer.startElement(HTML.DIV_ELEM, tabbedPane);
> >                     writer.writeAttribute(HTML.STYLE_ATTR,
> > "display:none", null);
> >                     RendererUtils.renderChild(facesContext, child);
> >                     writer.endElement(HTML.DIV_ELEM);
> >                 }
> >                 else
> >                 {
> >                     RendererUtils.renderChild(facesContext, child);
> >                 }
> >
> >                 tabIdx++;
> >             } else {
> >                 RendererUtils.renderChild(facesContext, child);
> >             }
> >         }
> >
> >         writer.endElement(HTML.TD_ELEM);
> >     }
> >
> >
> > A second change is necessary (we cannot only decode the visible
> > tab, all components are correctly rendered and must be decoded) in
> > HtmlPanelTabbedPane.processDecodes:
> >
> >
> > public void processDecodes(javax.faces.context.FacesContext context)
> >     {
> >         if (context == null) throw new NullPointerException
> > ("context");
> >         decode(context);
> >
> >         int tabIdx = 0;
> >         int selectedIndex = getSelectedIndex();
> >
> >         Iterator it = getFacetsAndChildren();
> >
> >         while (it.hasNext())
> >         {
> >             UIComponent childOrFacet = getUIComponent((UIComponent)
> > it.next());
> >             childOrFacet.processDecodes(context);
> >         }
> >     }
> >
> > I've tested my solution with the examples and Firefox 1.0.4
> > (LinuX). I'll test the solution with a IE in the next days.
> > I've changed the tabbedPane.jsp in the examples at the 3rd pane as
> > follows to test my solution:
> >
> > from:
> > <h:inputText id="inp3"/>
> > to:
> > <h:inputText id="inp3" required="true"/>
> >
> > I would propose this change in the examples for tests in the future.
> >
> >
> >
> >> 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
> >
> >
> >
> >
> 
>

Re: [jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by Jon Travis <jt...@p00p.org>.
Updated to HEAD to get this patch, but now nearly all my tab
functionality is broken.  I'll have more time to dig into
this later (though I may just revert my update and keep
going for a little while.)  getAsString in my converter
is called with "", for instance, so I'm getting things
like ClassCast exceptions, etc.

-- Jon


On May 22, 2005, at 6:49 AM, Philipp Ahlner (JIRA) wrote:

>      [ http://issues.apache.org/jira/browse/MYFACES-214? 
> page=comments#action_65954 ]
>
> Philipp Ahlner commented on MYFACES-214:
> ----------------------------------------
>
> Since many components (like HtmlSelectBooleanCheckbox) expects a  
> boolean value as submitted value (only the decode-method of each  
> renderer knows what type as submittedValue has to set), I'm tending  
> to discard the idea to "fake" submittedValue. I can now provide a  
> patch which hides the not-selected tabs with a <div  
> style="display:none">-tag. The disadvantage of this solution is  
> that the content of each tab is transferred to the browser, but  
> this solution never breaks the jsf-spec.
> Please forget all patches I've submitted before :-)
>
>
> I've changed the HtmlTabbedPaneRenderer.writeTabCell() method. If a  
> tab is hidden, the components are enclosed in a div tag.
>
> protected void writeTabCell(ResponseWriter writer, FacesContext  
> facesContext, HtmlPanelTabbedPane tabbedPane,
>             int tabCount, int selectedIndex) throws IOException {
>         HtmlRendererUtils.writePrettyLineSeparator(facesContext);
>         HtmlRendererUtils.writePrettyIndent(facesContext);
>         writer.startElement(HTML.TD_ELEM, tabbedPane);
>         writer.writeAttribute(HTML.COLSPAN_ATTR, Integer.toString 
> (tabCount + 1), null);
>         writer.writeAttribute(HTML.STYLE_ATTR, TAB_CELL_STYLE +  
> "background-color:" + tabbedPane.getBgcolor(), null);
>         HtmlRendererUtils.renderHTMLAttribute(writer, tabbedPane,  
> "tabContentStyleClass", HTML.STYLE_CLASS_ATTR);
>
>         int tabIdx = 0;
>         List children = tabbedPane.getChildren();
>         for (int i = 0, len = children.size(); i < len; i++) {
>             UIComponent child = getUIComponent((UIComponent)  
> children.get(i));
>             if (child instanceof HtmlPanelTab) {
>                 // the inactive tabs are hidden with a div-tag
>                 if (tabIdx != selectedIndex) {
>                     writer.startElement(HTML.DIV_ELEM, tabbedPane);
>                     writer.writeAttribute(HTML.STYLE_ATTR,  
> "display:none", null);
>                     RendererUtils.renderChild(facesContext, child);
>                     writer.endElement(HTML.DIV_ELEM);
>                 }
>                 else
>                 {
>                     RendererUtils.renderChild(facesContext, child);
>                 }
>
>                 tabIdx++;
>             } else {
>                 RendererUtils.renderChild(facesContext, child);
>             }
>         }
>
>         writer.endElement(HTML.TD_ELEM);
>     }
>
>
> A second change is necessary (we cannot only decode the visible  
> tab, all components are correctly rendered and must be decoded) in  
> HtmlPanelTabbedPane.processDecodes:
>
>
> public void processDecodes(javax.faces.context.FacesContext context)
>     {
>         if (context == null) throw new NullPointerException 
> ("context");
>         decode(context);
>
>         int tabIdx = 0;
>         int selectedIndex = getSelectedIndex();
>
>         Iterator it = getFacetsAndChildren();
>
>         while (it.hasNext())
>         {
>             UIComponent childOrFacet = getUIComponent((UIComponent)  
> it.next());
>             childOrFacet.processDecodes(context);
>         }
>     }
>
> I've tested my solution with the examples and Firefox 1.0.4  
> (LinuX). I'll test the solution with a IE in the next days.
> I've changed the tabbedPane.jsp in the examples at the 3rd pane as  
> follows to test my solution:
>
> from:
> <h:inputText id="inp3"/>
> to:
> <h:inputText id="inp3" required="true"/>
>
> I would propose this change in the examples for tests in the future.
>
>
>
>> 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
>
>
>
>


[jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by "Philipp Ahlner (JIRA)" <my...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/MYFACES-214?page=comments#action_65954 ]
     
Philipp Ahlner commented on MYFACES-214:
----------------------------------------

Since many components (like HtmlSelectBooleanCheckbox) expects a boolean value as submitted value (only the decode-method of each renderer knows what type as submittedValue has to set), I'm tending to discard the idea to "fake" submittedValue. I can now provide a patch which hides the not-selected tabs with a <div style="display:none">-tag. The disadvantage of this solution is that the content of each tab is transferred to the browser, but this solution never breaks the jsf-spec.
Please forget all patches I've submitted before :-)


I've changed the HtmlTabbedPaneRenderer.writeTabCell() method. If a tab is hidden, the components are enclosed in a div tag.

protected void writeTabCell(ResponseWriter writer, FacesContext facesContext, HtmlPanelTabbedPane tabbedPane,
            int tabCount, int selectedIndex) throws IOException {
        HtmlRendererUtils.writePrettyLineSeparator(facesContext);
        HtmlRendererUtils.writePrettyIndent(facesContext);
        writer.startElement(HTML.TD_ELEM, tabbedPane);
        writer.writeAttribute(HTML.COLSPAN_ATTR, Integer.toString(tabCount + 1), null);
        writer.writeAttribute(HTML.STYLE_ATTR, TAB_CELL_STYLE + "background-color:" + tabbedPane.getBgcolor(), null);
        HtmlRendererUtils.renderHTMLAttribute(writer, tabbedPane, "tabContentStyleClass", HTML.STYLE_CLASS_ATTR);

        int tabIdx = 0;
        List children = tabbedPane.getChildren();
        for (int i = 0, len = children.size(); i < len; i++) {
            UIComponent child = getUIComponent((UIComponent) children.get(i));
            if (child instanceof HtmlPanelTab) {
                // the inactive tabs are hidden with a div-tag
                if (tabIdx != selectedIndex) {
                    writer.startElement(HTML.DIV_ELEM, tabbedPane); 
                    writer.writeAttribute(HTML.STYLE_ATTR, "display:none", null);
                    RendererUtils.renderChild(facesContext, child);
                    writer.endElement(HTML.DIV_ELEM);
                }
                else
                {
                    RendererUtils.renderChild(facesContext, child);
                }
                                
                tabIdx++;
            } else {
                RendererUtils.renderChild(facesContext, child);
            }
        }

        writer.endElement(HTML.TD_ELEM);
    }


A second change is necessary (we cannot only decode the visible tab, all components are correctly rendered and must be decoded) in HtmlPanelTabbedPane.processDecodes:


public void processDecodes(javax.faces.context.FacesContext context)
    {
        if (context == null) throw new NullPointerException("context");
        decode(context);

        int tabIdx = 0;
        int selectedIndex = getSelectedIndex();

        Iterator it = getFacetsAndChildren();

        while (it.hasNext())
        {
            UIComponent childOrFacet = getUIComponent((UIComponent) it.next());
            childOrFacet.processDecodes(context);
        }
    }

I've tested my solution with the examples and Firefox 1.0.4 (LinuX). I'll test the solution with a IE in the next days.
I've changed the tabbedPane.jsp in the examples at the 3rd pane as follows to test my solution:

from:
<h:inputText id="inp3"/>
to:
<h:inputText id="inp3" required="true"/>

I would propose this change in the examples for tests in the future.


> 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


[jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by "Philipp Ahlner (JIRA)" <my...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/MYFACES-214?page=comments#action_65177 ]
     
Philipp Ahlner commented on MYFACES-214:
----------------------------------------

The rendered property of the components on the hidden tabs is not even false. Rendered is true regardless if the tab is hidden or not. Because rendered is true, the components should be validated - or not?

> 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


[jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by "Philipp Ahlner (JIRA)" <my...@incubator.apache.org>.
     [ 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


[jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by "Manfred Klug (JIRA)" <my...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/MYFACES-214?page=comments#action_65184 ]
     
Manfred Klug commented on MYFACES-214:
--------------------------------------

It's enough when the rendered property of a parent component is false (HtmlPanelTab in this case).

> 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


[jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by "Philipp Ahlner (JIRA)" <my...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/MYFACES-214?page=comments#action_65387 ]
     
Philipp Ahlner commented on MYFACES-214:
----------------------------------------

Yes, you're right. The line

if (submittedValue == null) return;

is totally correct according to spec 1.1 (Section 3.5.5). I've seen suche a statement also in sun's RI. Now, the question is how we get the tabbed pane working. I want to split a
dialog with many UIInput-components in a few tabs. The inputs belong to logical entity and must be validated together. I think this was the intention of the committer of the tab-impl. The UIInput-class is not the right point to solve this problem, but I don't give up :)
I've following idea to solve the problem in the renderer of the tabbedpane (it's only a outline):

We could implement encodeChildren(..) in org.apache.myfaces.custom.tabbedpane.HtmlTabbedPaneRenderer. The encodeChildren should have the same behavior like the standard impl. but after delegating the encoding to the children, the method can "simulate" a submit of all hidden components (overwrite submittedValue with the value (localValue) if not null or if null with an empty string). It sounds like a dirty hack, I fear it is one. It breaks the spec only a little bit :)
Better suggestions are welcome.

Philipp

> 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


[jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by "Manfred Klug (JIRA)" <my...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/MYFACES-214?page=comments#action_65140 ]
     
Manfred Klug commented on MYFACES-214:
--------------------------------------

There is only one problem with your solution.

The standard says that not rendered components are not validated (The same is
true if the submitted value is null).

You have found a bug, but not the expected one.

> 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


[jira] Commented: (MYFACES-214) TabbedPane : wrong validation behavior

Posted by "Philipp Ahlner (JIRA)" <my...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/MYFACES-214?page=comments#action_65243 ]
     
Philipp Ahlner commented on MYFACES-214:
----------------------------------------

The rendered-property of HtmlPanelTab is true, if not the clip (and the link for changing the activ tab) would not be shown. The children of the HtmlPanelTab are only "invisible" and such a invisibility is not defined in the JSF-spec. The hiding of components by HtmlPanelTab has no influence on the rendered property of any children.

> 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