You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Jan Bols <ja...@ivpv.ugent.be> on 2005/06/02 13:02:24 UTC
looses state when inside dataTable
I have the following form:
<h:form>
<x:dataTable var="data" value="#{test.dataModel2}">
<x:selectManyCheckbox id="items" layout="spread">
<f:selectItems value="#{test.items2}"/>
</x:selectManyCheckbox>
<h:column>
<x:checkbox for="items" index="#{test.dataModel2.rowIndex}"/>
</h:column>
</x:dataTable>
<x:selectManyCheckbox>
<f:selectItems value="#{test.items2}"/>
</x:selectManyCheckbox>
<h:commandButton value="Submit" />
</h:form>
As you can see it contains 2 times the same list of checkboxes and a
submit button. The first list of checkboxes is nested inside a dataTable.
This way I have some control over where the <x:checkbox> items must be
placed. The other list of checkboxes is just a plain selectManyCheckbox.
The problem is that the first list of checkboxes loses state after the
submit, while the second one doesn't (as is the normal behaviour). In
other words the first list doesn't work.
The managed bean test is hooked to this class:
public class Test {
private Collection items2;
private DataModel dataModel2;
public Test() {
items2 = new ArrayList(3);
items2.add(new SelectItem("200", "Duke's Quarterly", ""));
items2.add(new SelectItem("202", "Duke's Diet and Exercise Journal",
""));
items2.add(new SelectItem("201", "Innovator's Almanac", ""));
dataModel2 = new ListDataModel((List) items2);
}
public DataModel getDataModel2() {return dataModel2;}
public void setDataModel2(DataModel dataModel2) {this.dataModel2 =
dataModel2;}
public Collection getItems2() {return items2;}
public void setItems2(Collection items2) {this.items2 = items2;}
}
What am I doing wrong here? It seems really difficult to render checkboxes
inside dataTables.
Jan
Re: paginator, datatable and performance
Posted by Lking <lk...@yahoo.com.br>.
HelloDoes anyone find a way to do that? Thanks> I've read the link you
provide. This lets you retrieve from N to M
> records instead of every record that matches the criteria you're
> asking for.
> But in the case of pagination, once the dataScroller has arrived to
> the last record in the subset you have recovered from DB, how can you
> tell the component to continue retrieving more records (if they are
> available)? And also, if you only get a subset, how can the
> dataScroller now how many records are in total to show you the
> pagination?
> I've been thinking in this lazy pagination solution, and it would be
> perfect whether Hibernate could fecth in blocks. I mean, when you
> assign your Hibernate collection to the dataScroller, instead of
> materializing all the records, just materialize, for example, 100 (out
> of 10000). And then, when the next block is needed, lazy load it, and
> so on...
> What do you think?
On 4/23/05, Joshua Davis <[EMAIL PROTECTED]> wrote:
>
> The online documentation has an example here:
> http://www.hibernate.org/hib_docs/v3/reference/en/html/objectstate.html#obje
> ctstate-querying-executing-pagination
>
> The Query interface has two methods: setFirstResult(int) and
> setMaxResults(int).
> As usual, Hibernate takes care of making sure that this will work with the
> database you are using via it's 'Dialect' support. If you want to see
> how
> Hibernate does this for a specific database say, because you can't use
> Hibernate for your project, then download the source code and have a look
> at
> the Dialect classes.
>
> -----Original Message-----
> From: Enrique Medina [mailto:[EMAIL PROTECTED]
> Sent: Saturday, April 23, 2005 5:45 AM
> To: MyFaces Discussion
> Subject: Re: paginator, datatable and performance
>
> Hi Joshua,
>
> This is an insteresting issue. Could you give some extended information
> about Hibernat'es feature of row limit?
>
> On 4/22/05, Joshua Davis <[EMAIL PROTECTED]> wrote:
> > Easy... Just use Hibernate's row limit features in conjuction with the
> > paginator.
> >
> > [EMAIL PROTECTED]
> >
> > --- Slawek <[EMAIL PROTECTED]> wrote:
> > > hi
> > >
> > > suppose we have table in database containing many records (more than
> > > 10
> > > 000) and we want to display them in table...
> > > obiously we use paginator:)
> > >
> > > but we dont want to get all record form databese cause we need to
> > > wrap them "in fly" (or sth) - hevermind, lets just say that we can
> > > get at once from datatabse only 100 records (cause our table is set
> > > to show ony 100 rows).
> > > geting all 10 000 records and doing sht "in fly"
> > > would kill performance:/
> > >
> > > but to use paginator we must get all rows (paginator "take care"
> > > about counting and so on)
> > >
> > > is there any poibility to use standard paginator and not fetching
> > > all rows at once from database?
> > >
> > > S³awek
> > >
> >
>
>
____________________________________________________
Yahoo! Mail, cada vez melhor: agora com 1GB de espaço grátis! http://mail.yahoo.com.br
Re: looses state when inside dataTable
Posted by Sean Schofield <se...@gmail.com>.
Maybe your problem is related to this known issue
(http://issues.apache.org/jira/browse/MYFACES-228)
I will try to look into it. First I need to fix MYFACES-228 which has
been bothering me for a long time now. Perhaps the fix will lend
insight into your issue even if they are not the same. The key
difference between your problem and the known issue is that you are
not using sort header.
sean
On 6/2/05, Jan Bols <ja...@ivpv.ugent.be> wrote:
> I have the following form:
>
> <h:form>
> <x:dataTable var="data" value="#{test.dataModel2}">
> <x:selectManyCheckbox id="items" layout="spread">
> <f:selectItems value="#{test.items2}"/>
> </x:selectManyCheckbox>
>
> <h:column>
> <x:checkbox for="items" index="#{test.dataModel2.rowIndex}"/>
> </h:column>
> </x:dataTable>
>
> <x:selectManyCheckbox>
> <f:selectItems value="#{test.items2}"/>
> </x:selectManyCheckbox>
>
> <h:commandButton value="Submit" />
> </h:form>
>
> As you can see it contains 2 times the same list of checkboxes and a
> submit button. The first list of checkboxes is nested inside a dataTable.
> This way I have some control over where the <x:checkbox> items must be
> placed. The other list of checkboxes is just a plain selectManyCheckbox.
>
> The problem is that the first list of checkboxes loses state after the
> submit, while the second one doesn't (as is the normal behaviour). In
> other words the first list doesn't work.
>
> The managed bean test is hooked to this class:
>
> public class Test {
> private Collection items2;
> private DataModel dataModel2;
>
> public Test() {
> items2 = new ArrayList(3);
> items2.add(new SelectItem("200", "Duke's Quarterly", ""));
> items2.add(new SelectItem("202", "Duke's Diet and Exercise Journal",
> ""));
> items2.add(new SelectItem("201", "Innovator's Almanac", ""));
>
> dataModel2 = new ListDataModel((List) items2);
> }
> public DataModel getDataModel2() {return dataModel2;}
> public void setDataModel2(DataModel dataModel2) {this.dataModel2 =
> dataModel2;}
> public Collection getItems2() {return items2;}
> public void setItems2(Collection items2) {this.items2 = items2;}
> }
>
> What am I doing wrong here? It seems really difficult to render checkboxes
> inside dataTables.
>
> Jan
>