FAQ
I have a problem using the DataList component. I would like to use input
components within it, but the model isn't updated at all. I use a List a
the DataList value.
If I use a DataTable instead everything works fine.

Is this a bug, or does the DataList component not work with input
components (I guess it should, because it is a special DataTable) ?


here an example - does NOT work:

<h:form>
<x:dataList id="foo" var="item"
value="#{myBean.items}" >
<h:inputText value="#{item.value}" />
</x:dataList>

<h:commandButton action="save" />
</h:form>


but this works:

<h:form>
<h:dataTable id="foo" var="item"
value="#{myBean.items}" >
<h:inputText value="#{item.value}" />
</h:dataTable>

<h:commandButton action="save" />
</h:form>

Search Discussions

  • Brandon Goodin at May 3, 2005 at 5:59 pm
    I have had a similar issue with the commandLink. I filed a bug report.
    http://issues.apache.org/jira/browse/MYFACES-213. Maybe we can help
    each other figure out what it going on.

    Brandon

    On 5/3/05, mathias.werlitz@daimlerchrysler.com
    wrote:
    I have a problem using the DataList component. I would like to use input
    components within it, but the model isn't updated at all. I use a List a the
    DataList value.
    If I use a DataTable instead everything works fine.

    Is this a bug, or does the DataList component not work with input components
    (I guess it should, because it is a special DataTable) ?


    here an example - does NOT work:

    <h:form>
    <x:dataList id="foo" var="item"
    value="#{myBean.items}" >
    <h:inputText value="#{item.value}" />
    </x:dataList>

    <h:commandButton action="save" />
    </h:form>


    but this works:

    <h:form>
    <h:dataTable id="foo" var="item"
    value="#{myBean.items}" >
    <h:inputText value="#{item.value}" />
    </h:dataTable>

    <h:commandButton action="save" />
    </h:form>
  • Mathias Werlitz at May 4, 2005 at 1:28 pm
    Well I have some commandLink components nested in a dataList, too ... but
    the actions are invoked correctly. Here an example:

    <x:dataList id="superclasses"
    var="item"
    value="#{currentClass.directSuperclasses}"
    layout="simple"
    rowCountVar="rowCount"
    rowIndexVar="rowIndex" >

    <h:commandLink
    actionListener="#{currentClass.removeDirectSuperclass}"
    action="#{currentClass.save}"
    immediate="true">
    <h:graphicImage value="/images/delete.gif" />
    <f:param name="class" value="#{item}" />
    </h:commandLink>
    <h:commandLink styleClass="linkClass"
    actionListener="#{currentClass.loadClass}" action="editClass"
    immediate="true">
    <h:outputText value="#{item.name}" />
    <f:param name="class" value="#{item}" />
    </h:commandLink>
    </x:dataList>

    I guess it has something to do with the state of the nested components
    that is restored while the dataList component iterates over the list
    elements.
    Something seems to be broken or not completely implemented there.

    After some insight into the code i think the implementation of the
    following methods is missing in the dataList component:

    processValidators(context);
    processUpdates(context);

    If I have time, I will try to patch this.
  • Brandon Goodin at May 4, 2005 at 1:47 pm
    I think the bug i am facing has to do with the use of the binding
    attribute in the x:dataList tag instead of the value attribute. I'll
    just keep plugging away to see what the problem is. Thanks for the
    pointers on the unimplemented methods. I'll also see if my problems
    may have to do with something similar.

    Brandon

    On 5/4/05, mathias.werlitz@daimlerchrysler.com
    wrote:
    Well I have some commandLink components nested in a dataList, too ... but
    the actions are invoked correctly. Here an example:

    <x:dataList id="superclasses"
    var="item"
    value="#{currentClass.directSuperclasses}"
    layout="simple"
    rowCountVar="rowCount"
    rowIndexVar="rowIndex" >

    <h:commandLink
    actionListener="#{currentClass.removeDirectSuperclass}"
    action="#{currentClass.save}"
    immediate="true">
    <h:graphicImage value="/images/delete.gif" />
    <f:param name="class" value="#{item}" />
    </h:commandLink>
    <h:commandLink styleClass="linkClass"
    actionListener="#{currentClass.loadClass}" action="editClass"
    immediate="true">
    <h:outputText value="#{item.name}" />
    <f:param name="class" value="#{item}" />
    </h:commandLink>
    </x:dataList>

    I guess it has something to do with the state of the nested components that
    is restored while the dataList component iterates over the list elements.
    Something seems to be broken or not completely implemented there.

    After some insight into the code i think the implementation of the following
    methods is missing in the dataList component:

    processValidators(context);
    processUpdates(context);

    If I have time, I will try to patch this.
  • Mathias Werlitz at May 4, 2005 at 2:24 pm
    Well, I have found the problem AND a solution, maybe it will fix your
    problems, too.
    Opened a bug report: http://issues.apache.org/jira/browse/MYFACES-229

    Hope this helps.




    PROBLEM: Unimplemented methods in
    org.apache.myfaces.custom.datalist.HtmlDataList

    public void processUpdates(FacesContext context);
    public void processValidators(FacesContext context)

    SOLUTION:

    public void processUpdates(FacesContext context) {
    int first = getFirst();
    int rows = getRows();
    int last;
    if (rows == 0)
    {
    last = getRowCount();
    }
    else
    {
    last = first + rows;
    }
    for (int rowIndex = first; rowIndex < last; rowIndex++)
    {
    setRowIndex(rowIndex);
    if (isRowAvailable())
    {
    for (Iterator it = getChildren().iterator();
    it.hasNext();)
    {
    UIComponent child = (UIComponent)it.next();
    if (!child.isRendered())
    {
    continue;
    }
    child.processUpdates(context);
    }
    }
    }

    setRowIndex(-1);
    }


    public void processValidators(FacesContext context) {
    int first = getFirst();
    int rows = getRows();
    int last;
    if (rows == 0)
    {
    last = getRowCount();
    }
    else
    {
    last = first + rows;
    }
    for (int rowIndex = first; rowIndex < last; rowIndex++)
    {
    setRowIndex(rowIndex);
    if (isRowAvailable())
    {
    for (Iterator it = getChildren().iterator();
    it.hasNext();)
    {
    UIComponent child = (UIComponent)it.next();
    if (!child.isRendered())
    {
    continue;
    }
    child.processValidators(context);
    }
    }
    }

    setRowIndex(-1);
    }
  • Brandon Goodin at May 4, 2005 at 2:35 pm
    but it extends UIData which DOES implement those.

    On 5/4/05, mathias.werlitz@daimlerchrysler.com
    wrote:
    Well, I have found the problem AND a solution, maybe it will fix your
    problems, too.
    Opened a bug report:
    http://issues.apache.org/jira/browse/MYFACES-229

    Hope this helps.




    PROBLEM: Unimplemented methods in
    org.apache.myfaces.custom.datalist.HtmlDataList

    public void processUpdates(FacesContext context);
    public void processValidators(FacesContext context)

    SOLUTION:

    public void processUpdates(FacesContext context) {
    int first = getFirst();
    int rows = getRows();
    int last;
    if (rows == 0)
    {
    last = getRowCount();
    }
    else
    {
    last = first + rows;
    }
    for (int rowIndex = first; rowIndex < last; rowIndex++)
    {
    setRowIndex(rowIndex);
    if (isRowAvailable())
    {
    for (Iterator it = getChildren().iterator(); it.hasNext();)
    {
    UIComponent child = (UIComponent)it.next();
    if (!child.isRendered())
    {
    continue;
    }
    child.processUpdates(context);
    }
    }
    }

    setRowIndex(-1);
    }


    public void processValidators(FacesContext context) {
    int first = getFirst();
    int rows = getRows();
    int last;
    if (rows == 0)
    {
    last = getRowCount();
    }
    else
    {
    last = first + rows;
    }
    for (int rowIndex = first; rowIndex < last; rowIndex++)
    {
    setRowIndex(rowIndex);
    if (isRowAvailable())
    {
    for (Iterator it = getChildren().iterator(); it.hasNext();)
    {
    UIComponent child = (UIComponent)it.next();
    if (!child.isRendered())
    {
    continue;
    }
    child.processValidators(context);
    }
    }
    }

    setRowIndex(-1);
    }


  • Mathias Werlitz at May 4, 2005 at 3:16 pm
    Yes it does, but it does not use <h:column> sub components to wrap the
    nested components and the dataTable implementation assumes this.
    Therefor the dataTable component overwrites the processDecodes() method
    correctly. This is also were I got the code from.

    I guess the other methods were simply forgotten.

    After adding the code to the component it does work correctly for me.
  • Martin Marinschek at May 4, 2005 at 3:19 pm
    Well, in ancient times dataTable did not work for inputComponents
    either, so the code has been added to dataTable, but for dataList
    nobody ever complained ;)

    thanks for the patch,

    regards,

    Martin

    On 5/4/05, mathias.werlitz@daimlerchrysler.com
    wrote:
    Yes it does, but it does not use <h:column> sub components to wrap the
    nested components and the dataTable implementation assumes this.
    Therefor the dataTable component overwrites the processDecodes() method
    correctly. This is also were I got the code from.

    I guess the other methods were simply forgotten.

    After adding the code to the component it does work correctly for me.
  • Brandon Goodin at May 4, 2005 at 3:19 pm
    aha! i see. Yes. The UIData process columns and facests then ignores
    anything else. Interesting.

    On 5/4/05, mathias.werlitz@daimlerchrysler.com
    wrote:
    Yes it does, but it does not use <h:column> sub components to wrap the
    nested components and the dataTable implementation assumes this.
    Therefor the dataTable component overwrites the processDecodes() method
    correctly. This is also were I got the code from.

    I guess the other methods were simply forgotten.

    After adding the code to the component it does work correctly for me.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriesmyfaces
postedMay 3, '05 at 11:21a
activeMay 4, '05 at 3:19p
posts9
users3
websitemyfaces.apache.org

People

Translate

site design / logo © 2019 Grokbase