You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by kin <lk...@yahoo.com.br> on 2005/04/13 14:35:54 UTC

DataTable and Scroller

Hi

    I'm new to JSF and I'm trying MyFaces. I just made a page with 
x:dataTable and x:scroller but I'm having some troubles.

    The first one is that x:dataTable has a column with checkBox. If I 
check a box, then all the same rows in all the diff. pages are going to 
be checked. How to solve that?

    The second is that I need to get the page index in my backing bean. 
I thought binding it as pageIndexVar="#{bean.property}" would solve my 
problem, but it's not working.

    Any suggestions?

Thanks, lkin.

Re: DataTable and Scroller

Posted by Sean Schofield <se...@gmail.com>.
I haven't experimented with checkboxes in dataTable yet but I did just
recently add a few new dataTable examples to the simple examples. 
They are in CVS now and should be in tonights "nightly."  They show
some functionality that was previously unknown to me and probably most
other people.

sean

On 4/13/05, Enrique Medina <e....@gmail.com> wrote:
> Hi,
> 
> No, I didn't mean to unbind your checkbox, but to do it, so every time
> the component gets rendered, it will look at that value to see whether
> it must be checked or not. Maybe the problem you are facing is the
> well-known problem with checkboxes about false ones not being
> submitted by the browser. I remember having that problem in Struts:
> 
> http://struts.apache.org/faqs/newbie.html#checkbox
> 
> With respect to the other functionality you need, I must say that the
> component does not provide it. Making a rapid think effort, you could
> get that behaviour using hidden fields, whose value is taken from the
> dataScroller attributes and binding them to one of your bean's
> property. Something like this:
> 
> <x:dataScroller id="scroll_2"
>                            for="data"
>                            rowsCountVar="rowsCount"
>                            displayedRowsCountVar="displayedRowsCountVar"
>                            firstRowIndexVar="firstRowIndex"
>                            lastRowIndexVar="lastRowIndex"
>                            pageCountVar="pageCount"
>                            pageIndexVar="pageIndex"
>                            >
>                        <h:hidden value="#{pageIndex}"
> binding="#{myBean.myProperty}"/>
>                    </x:dataScroller>
> 
> But I don't know if this would be the best approach...
> 
> Anyone can provide any ideas?
> 
> On 4/13/05, kin <lk...@yahoo.com.br> wrote:
> >  Enrique
> >
> >      Thanks for answering.
> >
> >      I've got some doubts from your reply.
> >
> >      If I don't bind my checkbox how can I know in my backing bean whether
> > it's checked?
> >
> >      And about finding the page index where I'm in, I got the example and it
> > worked ok if I needed to display the value in my page, as the example. But
> > I'm wanting to get this value in my backing bean and this is what I'm not
> > getting. I'm sorry if I missed something from your reply.
> >
> >  Thanks.
> >
> >  Enrique Medina escreveu:
> >  Hi,
> >
> > The answer to your first problem is that you might have a checkbox not
> > bind to a model value, so it simply renders as previous.
> >
> > With respect to the second problem, you can use the attributes in the
> > <x:dataScroller> tag:
> >
> >  <x:dataScroller id="scroll_2"
> >  for="data"
> >  rowsCountVar="rowsCount"
> >  displayedRowsCountVar="displayedRowsCountVar"
> >  firstRowIndexVar="firstRowIndex"
> >  lastRowIndexVar="lastRowIndex"
> >  pageCountVar="pageCount"
> >  pageIndexVar="pageIndex"
> >  >
> >  <h:outputFormat
> > value="#{example_messages['dataScroller_pages']}"
> > styleClass="standard" >
> >  <f:param value="#{rowsCount}" />
> >  <f:param value="#{displayedRowsCountVar}" />
> >  <f:param value="#{firstRowIndex}" />
> >  <f:param value="#{lastRowIndex}" />
> >  <f:param value="#{pageIndex}" />
> >  <f:param value="#{pageCount}" />
> >  </h:outputFormat>
> >  </x:dataScroller>
> >
> > Take a look at webapp examples from MyFaces ;-)
> >
> > On 4/13/05, kin <lk...@yahoo.com.br> wrote:
> >
> >
> >  Hi
> >
> >  I'm new to JSF and I'm trying MyFaces. I just made a page with
> > x:dataTable and x:scroller but I'm having some troubles.
> >
> >  The first one is that x:dataTable has a column with checkBox. If I
> > check a box, then all the same rows in all the diff. pages are going to
> > be checked. How to solve that?
> >
> >  The second is that I need to get the page index in my backing bean.
> > I thought binding it as pageIndexVar="#{bean.property}" would solve my
> > problem, but it's not working.
> >
> >  Any suggestions?
> >
> > Thanks, lkin.
> >
> >
> >
> >
> >
>

Re: DataTable and Scroller

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

No, I didn't mean to unbind your checkbox, but to do it, so every time
the component gets rendered, it will look at that value to see whether
it must be checked or not. Maybe the problem you are facing is the
well-known problem with checkboxes about false ones not being
submitted by the browser. I remember having that problem in Struts:

http://struts.apache.org/faqs/newbie.html#checkbox

With respect to the other functionality you need, I must say that the
component does not provide it. Making a rapid think effort, you could
get that behaviour using hidden fields, whose value is taken from the
dataScroller attributes and binding them to one of your bean's
property. Something like this:

<x:dataScroller id="scroll_2"
                           for="data"
                           rowsCountVar="rowsCount"
                           displayedRowsCountVar="displayedRowsCountVar"
                           firstRowIndexVar="firstRowIndex"
                           lastRowIndexVar="lastRowIndex"
                           pageCountVar="pageCount"
                           pageIndexVar="pageIndex"
                           >
                       <h:hidden value="#{pageIndex}"
binding="#{myBean.myProperty}"/>
                   </x:dataScroller>

But I don't know if this would be the best approach...

Anyone can provide any ideas?

On 4/13/05, kin <lk...@yahoo.com.br> wrote:
>  Enrique
>  
>      Thanks for answering.
>  
>      I've got some doubts from your reply.
>  
>      If I don't bind my checkbox how can I know in my backing bean whether
> it's checked?
>  
>      And about finding the page index where I'm in, I got the example and it
> worked ok if I needed to display the value in my page, as the example. But
> I'm wanting to get this value in my backing bean and this is what I'm not
> getting. I'm sorry if I missed something from your reply.
>  
>  Thanks.
>  
>  Enrique Medina escreveu: 
>  Hi,
> 
> The answer to your first problem is that you might have a checkbox not
> bind to a model value, so it simply renders as previous.
> 
> With respect to the second problem, you can use the attributes in the
> <x:dataScroller> tag:
> 
>  <x:dataScroller id="scroll_2"
>  for="data"
>  rowsCountVar="rowsCount"
>  displayedRowsCountVar="displayedRowsCountVar"
>  firstRowIndexVar="firstRowIndex"
>  lastRowIndexVar="lastRowIndex"
>  pageCountVar="pageCount"
>  pageIndexVar="pageIndex"
>  >
>  <h:outputFormat
> value="#{example_messages['dataScroller_pages']}"
> styleClass="standard" >
>  <f:param value="#{rowsCount}" />
>  <f:param value="#{displayedRowsCountVar}" />
>  <f:param value="#{firstRowIndex}" />
>  <f:param value="#{lastRowIndex}" />
>  <f:param value="#{pageIndex}" />
>  <f:param value="#{pageCount}" />
>  </h:outputFormat>
>  </x:dataScroller>
> 
> Take a look at webapp examples from MyFaces ;-)
> 
> On 4/13/05, kin <lk...@yahoo.com.br> wrote:
>  
>  
>  Hi
> 
>  I'm new to JSF and I'm trying MyFaces. I just made a page with
> x:dataTable and x:scroller but I'm having some troubles.
> 
>  The first one is that x:dataTable has a column with checkBox. If I
> check a box, then all the same rows in all the diff. pages are going to
> be checked. How to solve that?
> 
>  The second is that I need to get the page index in my backing bean.
> I thought binding it as pageIndexVar="#{bean.property}" would solve my
> problem, but it's not working.
> 
>  Any suggestions?
> 
> Thanks, lkin.
> 
>  
>  
>  
>

Re: DataTable and Scroller

Posted by kin <lk...@yahoo.com.br>.
Enrique

    Thanks for answering.

    I've got some doubts from your reply.

    If I don't bind my checkbox how can I know in my backing bean 
whether it's checked?

    And about finding the page index where I'm in, I got the example and 
it worked ok if I needed to display the value in my page, as the 
example. But I'm wanting to get this value in my backing bean and this 
is what I'm not getting. I'm sorry if I missed something from your reply.

Thanks.

Enrique Medina escreveu:

>Hi,
>
>The answer to your first problem is that you might have a checkbox not
>bind to a model value, so it simply renders as previous.
>
>With respect to the second problem, you can use the attributes in the
><x:dataScroller> tag:
>
>                    <x:dataScroller id="scroll_2"
>                            for="data"
>                            rowsCountVar="rowsCount"
>                            displayedRowsCountVar="displayedRowsCountVar"
>                            firstRowIndexVar="firstRowIndex"
>                            lastRowIndexVar="lastRowIndex"
>                            pageCountVar="pageCount"
>                            pageIndexVar="pageIndex"
>                            >
>                        <h:outputFormat
>value="#{example_messages['dataScroller_pages']}"
>styleClass="standard" >
>                            <f:param value="#{rowsCount}" />
>                            <f:param value="#{displayedRowsCountVar}" />
>                            <f:param value="#{firstRowIndex}" />
>                            <f:param value="#{lastRowIndex}" />
>                            <f:param value="#{pageIndex}" />
>                            <f:param value="#{pageCount}" />
>                        </h:outputFormat>
>                    </x:dataScroller>
>
>Take a look at webapp examples from MyFaces ;-)
>
>On 4/13/05, kin <lk...@yahoo.com.br> wrote:
>  
>
>>Hi
>>
>>    I'm new to JSF and I'm trying MyFaces. I just made a page with
>>x:dataTable and x:scroller but I'm having some troubles.
>>
>>    The first one is that x:dataTable has a column with checkBox. If I
>>check a box, then all the same rows in all the diff. pages are going to
>>be checked. How to solve that?
>>
>>    The second is that I need to get the page index in my backing bean.
>>I thought binding it as pageIndexVar="#{bean.property}" would solve my
>>problem, but it's not working.
>>
>>    Any suggestions?
>>
>>Thanks, lkin.
>>
>>    
>>
>
>  
>


Re: DataTable and Scroller

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

The answer to your first problem is that you might have a checkbox not
bind to a model value, so it simply renders as previous.

With respect to the second problem, you can use the attributes in the
<x:dataScroller> tag:

                    <x:dataScroller id="scroll_2"
                            for="data"
                            rowsCountVar="rowsCount"
                            displayedRowsCountVar="displayedRowsCountVar"
                            firstRowIndexVar="firstRowIndex"
                            lastRowIndexVar="lastRowIndex"
                            pageCountVar="pageCount"
                            pageIndexVar="pageIndex"
                            >
                        <h:outputFormat
value="#{example_messages['dataScroller_pages']}"
styleClass="standard" >
                            <f:param value="#{rowsCount}" />
                            <f:param value="#{displayedRowsCountVar}" />
                            <f:param value="#{firstRowIndex}" />
                            <f:param value="#{lastRowIndex}" />
                            <f:param value="#{pageIndex}" />
                            <f:param value="#{pageCount}" />
                        </h:outputFormat>
                    </x:dataScroller>

Take a look at webapp examples from MyFaces ;-)

On 4/13/05, kin <lk...@yahoo.com.br> wrote:
> Hi
> 
>     I'm new to JSF and I'm trying MyFaces. I just made a page with
> x:dataTable and x:scroller but I'm having some troubles.
> 
>     The first one is that x:dataTable has a column with checkBox. If I
> check a box, then all the same rows in all the diff. pages are going to
> be checked. How to solve that?
> 
>     The second is that I need to get the page index in my backing bean.
> I thought binding it as pageIndexVar="#{bean.property}" would solve my
> problem, but it's not working.
> 
>     Any suggestions?
> 
> Thanks, lkin.
>