You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by ma...@daimlerchrysler.com on 2005/05/03 13:20:31 UTC
DataList does not work correctly like a DataTable with input components
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>
Re: Re: Re: Re: DataList does not work correctly like a DataTable with input components
Posted by Martin Marinschek <ma...@gmail.com>.
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
<ma...@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.
>
Re: Re: Re: Re: DataList does not work correctly like a DataTable with input components
Posted by Brandon Goodin <br...@gmail.com>.
aha! i see. Yes. The UIData process columns and facests then ignores
anything else. Interesting.
On 5/4/05, mathias.werlitz@daimlerchrysler.com
<ma...@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.
>
Antwort: Re: Re: Re: DataList does not work correctly like a DataTable
with input components
Posted by ma...@daimlerchrysler.com.
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.
Re: Re: Re: DataList does not work correctly like a DataTable with input components
Posted by Brandon Goodin <br...@gmail.com>.
but it extends UIData which DOES implement those.
On 5/4/05, mathias.werlitz@daimlerchrysler.com
<ma...@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);
> }
>
>
>
>
Antwort: Re: Re: DataList does not work correctly like a DataTable
with input components
Posted by ma...@daimlerchrysler.com.
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);
}
Re: Re: DataList does not work correctly like a DataTable with input components
Posted by Brandon Goodin <br...@gmail.com>.
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
<ma...@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.
Re: Re: DataList does not work correctly like a DataTable with input
components
Posted by ma...@daimlerchrysler.com.
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.
Re: DataList does not work correctly like a DataTable with input components
Posted by Brandon Goodin <br...@gmail.com>.
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
<ma...@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>