myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Robinson" <andrew.rw.robin...@gmail.com>
Subject Re: dataTable - only show first 10 results
Date Thu, 14 Jun 2007 14:49:17 GMT
Why not limit the number of rows bound to the DataModel in the backing
bean? Then have an action listener on the show all button that changes
the method to return the data without the limit.

private boolean limitRows = true;
private List data;
public boolean isLimitRows() { return this.limitRows; }
public void setLimitRows(boolean limitRows) { this.limitRows = limitRows; }
public List getData() {
  if (limitRows) {
    return data.subList(0, Math.max(10, data.size()));
  } else {
    return data;
  }
}

<h:dataTable value="#{bean.data}" var="_row">
  <f:facet name="header">
    <h:panelGroup>
      <h:commandLink value="Show all" rendered="#{bean.limitRows}">
        <t:updateActionListener property="#{bean.limitRows}" value="#{false}" />
      </h:commandLink>
      <h:commandLink value="Show first 10" rendered="#{not bean.limitRows}">
        <t:updateActionListener property="#{bean.limitRows}" value="#{true}" />
      </h:commandLink>
    </h:panelGroup>
  </f:facet>
  <h:column>
  ...
</h:dataTable>


On 6/14/07, geirgp <geirgp@gmail.com> wrote:
>
> I'm totally new to JavaScript and JSF, so I'm seeking a bit of advise here..
>
> I want to hide all but the first 10 rows in a dataTable and have a link
> (javascript) "Show all" that reveals the hidden rows when clicked.
>
> Any ideas?
>
> Thanks in advance
> --
> View this message in context: http://www.nabble.com/dataTable---only-show-first-10-results-tf3921795.html#a11120357
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Mime
View raw message