Sorting a JSF dataTable

Hi all,
How can the contents of JSF dataTable component be sorted (any column). I need solution in JSF.
can any one show an example or code snippet.
I have this code of dataTable and I want to sort it by Date Created.
How I can associate my code of sort with this column.
<h:dataTable value="#{viewCampaignPageBean.allCampaigns}" var="campaign"
border="1" width="60%" cellpadding = "4" styleClass= "sample" headerClass="th"
>
<h:column>
<f:facet name="header">
<f:verbatim>Title</f:verbatim>
</f:facet>
<h:outputText value="#{campaign.title}" styleClass="tLabel" />
</h:column>
<h:column>
<f:facet name="header">
<f:verbatim>Type</f:verbatim>
</f:facet>
<h:outputText value="#{campaign.campaignType}" styleClass="tLabel" />
</h:column>
<h:column>
<f:facet name="header">
<f:verbatim>Date Created</f:verbatim>
</f:facet>
<h:outputText value="#{campaign.createDate}" styleClass="tLabel" />
</h:column>
</h:dataTable>Thanks in advance

Check <a href="http://balusc.xs4all.nl/srv/dev-jep-dat.html"></a> � <a href="http://balusc.xs4all.nl/srv/dev-jep-dat.html#SortingDatatable"></a>.

Similar Messages

  • JSF dataTables - Problem during retrieving data from bean

    Hi, Below is the Stack Trace got on displaying data using JSF datatables.
         This error occurs somtimes and is not very frequent.We are using jboss seam, jboss-4.0.5.GA server and Hibernate.
         Anyone knows about this problem and how it can be resolved?
         Thanks in advance
         javax.faces.el.EvaluationException: Cannot get value for expression '#{loc.companyName}'
              at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:402)
              at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:1075)
              at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:508)
              at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild(RendererUtils.java:433)
              at org.apache.myfaces.shared_impl.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:216)
              at org.apache.myfaces.shared_impl.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:98)
              at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:536)
              at javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:495)
              at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:363)
              at org.apache.myfaces.shared_impl.taglib.UIComponentBodyTagBase.doEndTag(UIComponentBodyTagBase.java:54)
              at org.apache.jsp.menu_jsp._jspx_meth_h_panelGrid_0(menu_jsp.java:225)
              at org.apache.jsp.menu_jsp._jspx_meth_f_subview_0(menu_jsp.java:118)
              at org.apache.jsp.menu_jsp._jspService(menu_jsp.java:87)
              at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
              at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
              at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
              at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
              at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:574)
              at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:499)
              at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
              at org.apache.jsp.finish_005fregistration_jsp._jspx_meth_h_form_0(finish_005fregistration_jsp.java:263)
              at org.apache.jsp.finish_005fregistration_jsp._jspx_meth_f_view_0(finish_005fregistration_jsp.java:139)
              at org.apache.jsp.finish_005fregistration_jsp._jspService(finish_005fregistration_jsp.java:93)
              at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
              at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
              at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
              at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
              at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
              at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
              at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
              at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:416)
              at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
              at org.jboss.seam.jsf.SeamViewHandler.renderView(SeamViewHandler.java:59)
              at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at com.kmedia.filter.RequestFilter.doFilter(RequestFilter.java:184)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
              at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
              at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
              at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
              at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
              at java.lang.Thread.run(Thread.java:595)
         Caused by: java.lang.NullPointerException
              at org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:620)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
              at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:464)
              at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:405)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
              at org.jboss.seam.jsf.SeamApplication11.getPropertyResolver(SeamApplication11.java:197)
              at org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java:532)
              at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
              at org.apache.commons.el.BinaryOperatorExpression.evaluate(BinaryOperatorExpression.java:154)
              at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:383)
              ... 70 more
         10:23:55 Servlet.service() for servlet jsp threw exception
         Also check the JSF page, Backing bean, and VO
         JSF page
         <h:dataTable value="#{finishedRegistrationBean.list}" var = "loc" >
                        <h:column>
         <f:facet name="header">
                        <h:outputText value="#{displaymessages.registrationDate}" />
                        </f:facet>
                        <span class="bodylighttext"> <h:outputText value="#{loc.registrDate}" /> </span>
                                                                                                   </h:column>
                        <h:column>
                        <f:facet name="header">
                        <h:outputText value="#{displaymessages.companyName}" />
                        </f:facet>
                        <span class="bodylighttext"> <h:outputText
                        value="#{loc.companyName}" /> </span>
                        </h:column>
                        <h:column>
                        <f:facet name="header">
                             <h:outputText value="#{displaymessages.Address}" />
                             </f:facet>
                        <span class="bodylighttext"> <h:outputText
                        value="#{loc.address}" /> </span>
                        </h:column>
                        <h:column>
                        <f:facet name="header">
                        <h:outputText value="#{displaymessages.Action}" />
                        </f:facet>
                        <h:commandLink target="_blank"
                        action="#{finishedRegistrationBean.viewFinishedRegistrationPage(loc)}">
                        <h:graphicImage value="images/view_icon.gif"
                        alt="#{displaymessages.info_tooltip_view}"
                        width="17" height="17" style="border:0" />
                        </h:commandLink>
                        </h:column>
    </h:dataTable>
    Backing bean
                        @Name("finishedRegistrationBean")
                        public class FinishedRegistrationBean {
                             @In
                             private User user;
                             @In
                             private FacesMessages facesMessages;
                             private List<FinishedRegistrationVO> list;
                             public FinishedRegistrationBean() throws KMException {
                                  filterFinishedRegistration();
                             public void filterFinishedRegistration() throws KMException
                             list = new ArrayList<FinishedRegistrationVO>();
                             finished_list = userDAO.searchFinishedRegistrationDetails(country_code,uniqueID, companyName, user.getUserName());
                             public void setList(List<FinishedRegistrationVO> list) {
                                  this.list = list;
                             public List<FinishedRegistrationVO> getList() {
                             return list;
    FinishedRegistrationVO
         public class FinishedRegistrationVO {
              private String uniqId;
              private String companyName;
              private Date registrDate;
              private String address;
              public String getCompanyName() {
                   return companyName;
              public void setCompanyName(String companyName) {
                   this.companyName = companyName;
              public String getAddress() {
                   return address;
              public void setAddress(String address) {
                   this.address = address;
              public String getUniqId() {
                   return uniqId;
              public void setUniqId(String uniqId) {
                   this.uniqId = uniqId;
              public Date getRegistrDate() {
                   return registrDate;
              public void setRegistrDate(Date registrDate) {
                   this.registrDate = registrDate;
         }

    Could you please post your
    -HBM
    -faces-config.xml

  • EL Expression in a JSF Datatable

    I have a JSF Datatable that returns a list of results. These results contain a short version of what I actually want to display. For example, "DOC" which stands for "Document". Is there a way that I can create an EL expression inside the Datatable to print out the full name instead of the shortened name?

    jmsjr wrote:
    gimbal2 wrote:
    IMO this requirement, if it is possible to implement, is only going to lead to a hard to maintain application. But I guess that's something you have to experience before you believe it.
    You can't use EL directly in a resource bundle out of the box, but it is possible to parametrize them anyway, did you know that? Perhaps that is already good enough for you.
    http://murygin.wordpress.com/2010/04/23/parameter-substitution-in-resource-bundles/
    http://stackoverflow.com/questions/5697189/pass-parameters-to-messages-from-resource-bundle-to-components-other-than-hou
    Yes, I am aware of parameterising the resource bundles. However, these require you to use f:param .. and the last time I tried, these parameters were not available / visible at the requiredMessage attribute. I'll try it again anyway.As I have re-discovered, you cannot parameterise the requiredMessage attribute.
    http://stackoverflow.com/questions/9280915/how-to-parameterize-requiredmessage-attribute-in-composite-component
    The other alternative I am looking at, for the cases where the requiredMessage needs to be parameterised, or needs to have dynamic content, is to call a backing method for the requiredMessage attribute, from which I can then do whatever I need, even use EL expressions. I was thinking of this as a last resort.
    On the other hand, when one uses the validator attribute, usually one ends up adding one or multiple FacesMessage in code within the method being called, where the string of the message already comes from a resource bundle. I was trying to have a delineation whereby:
    1) requiredMessage should only use resource bundles, no backing bean method called.
    2) FacesMessages added via the method called by the validator attribute is OK

  • JSF Datatable row data - Expand/Collapse

    Hi,
    I just started learning the JSF concepts. I read articles by BalusC which are very clear and easily understandable. Thanks to BalusC.
    I have a requirement to implement expand and collapse data using JSF datatable. The data comes from the backing bean is in the form of java.util.List which contains StudentInfo. I will have to display following data from the list.
    *{color:#0000ff}name {color}(this is to be displayed a link), firstname, lastname, dob*
    I am able to display the data in a nice formatted table using h:datatable. My main hurdle is to display an expanded info when the name link is clicked. The expanded info should be displayed below the row spanning all columns. The additional info being the comments, instructions whic are the part of the row data. Here is the code describing the StudentInfo.
    Appreciate if someone help me with suggestions. Very helpful if any sample code is avaialble.
    Regards,
    Smitha
    public class StudentInfo {
    //Following fields to be shown in row data
    private String name;
    private String firstname;
    private String lastname;
    private String dob;
    //Following fields to be shown in expanded form
    private String comments;
    private String instructions;
    public String getName() {
    return name;
    public void setName(String name) {
    this.name = name;
    public String getFirstname() {
    return firstname;
    public void setFirstname(String firstname) {
    this.firstname = firstname;
    public String getLastname() {
    return lastname;
    public void setLastname(String lastname) {
    this.lastname = lastname;
    public String getDob() {
    return dob;
    public void setDob(String dob) {
    this.dob = dob;
    public String getComments() {
    return comments;
    public void setComments(String comments) {
    this.comments = comments;
    public String getInstructions() {
    return instructions;
    public void setInstructions(String instructions) {
    this.instructions = instructions;
    }

    That's not possible with plain h:dataTable.
    Consider Tomahawk t:dataList where in you can specify rows and colspans yourself using plain HTML. Show/hide rows should be easy with JavaScript.

  • Jsf datatable component + java.sql.SQLException

    I get the following error when implementing a JSF DataTable component using
    JDeveloper 10.1.3.1.
    javax.faces.FacesException: java.sql.SQLException: Io exception: Socket closed
    I am able to follow the article in this link:
    http://www.oracle.com/technology/oramag/oracle/06-jan/o16jsf.html
    I can get the table generated, but it occurred to me that the example in this article does not include logic to close the statement, resultset, and connection. Sure enough, I jumped out to the database and there were numerous inactive connections hanging around from my application.
    I added the following code before the return null statement from the article:
    finally {
    try {
    rs.close();
    stmt.close();
    c.close();
    catch (Exception e) {
    System.out.println("after close");
    So I need to know the proper procedure to closing the resultset, statement, and connection using a jsf datatable component.

    You need to make sure you're using the Oracle9i JDBC driver, or using the Oracle 8.1.7.2 JDBC driver as I mentioned above.
    If you are using JDeveloper9i release 9.0.2 or 9.0.3, the driver you need is in <jdevhome>\jdbc\lib
    Otherwise, you can also download the drivers from OTN.

  • H:message inside a JSF Datatable

    Is it possible to put an < h:message> inside of a column of a JSF Datatable? I want to validate that the user is actually entering data into the text box residing in the column of the Datatable.

    Yes, you could, please download jsf1.1 RI and install the jsf-components smaple and then refer this page:
    http://localhost:8080/jsf-components/repeater.faces

  • How to dynamically create a JSF dataTable from a String[][] array

    Hi, I�m developing an application that uses columns, rows and data instead of any other attributes, so I got from a database Resultset a String[] array with the rows headers, other String[] array with the columns headers, and a String[][] array with the information between every row[] and column[] header al this String arrays depend on a method that receives the group title as a parameter so they are dynamically created, anyway I can display this information in a jsp page but I don�t know how to display this information in a JSF dataTable.
    Does anybody knows how I could do this? and which is the proper way to create a dynamically rows and columns dataTable?

    Hi, I�m developing an application that uses columns, rows and data instead of any other attributes, so I got from a database Resultset a String[] array with the rows headers, other String[] array with the columns headers, and a String[][] array with the information between every row[] and column[] header al this String arrays depend on a method that receives the group title as a parameter so they are dynamically created, anyway I can display this information in a jsp page but I don�t know how to display this information in a JSF dataTable.
    Does anybody knows how I could do this? and which is the proper way to create a dynamically rows and columns dataTable?

  • Question about jdbc and jsf datatable

    hello
    I was wondering whether it was a correct way :
    -retrieving data with resultset and putting them to an arraylist, then getting to jsf datatable.
    or
    Is there any better way I can speed up retrieving data from databse ?
    regards

    orkun wrote:
    I was wondering whether it was a correct way :
    -retrieving data with resultset and putting them to an arraylist, then getting to jsf datatable.Your question/problem statement is unclear, but just lookup the DAO pattern.
    Is there any better way I can speed up retrieving data from databse ?Performance is a matter of good code and datamodel and decent hardware.

  • Selecting multiple rows from jsf datatable

    Hi
    i am working on jsf,ejb3.0 .my requirement is to select the multiple rows usng checkboxes from jsf datatable. i am workng on this for last two days. early response is appreciated.please hel me.
    Thanks
    KRamu

    Hi!
    You could enhance your collection item with a boolean. On your interface you then insert a checkbox column that you bind to the boolean property. on any given action you can go thru your collection and check which item has been selected. In case of doubt go to [http://balusc.blogspot.com/] -i'm sure you'll find some samples/tuts there.

  • Problem with jsf DataTable

    when data is fetch using user criteria:
    i have a problem with jsf DataTable. I use e request bean to populate the datatable and i insert a commandButton column. The data dispay successfully into the datatable, but when a push the button on the row...the page simply refresh and notinhg else
    when data is fetch using constants:
    The data dispay successfully into the datatable, when a push the button on the row...the action execute OK

    Hi,
    I don't think that with this description only anybody on this list is able to help you.
    I use e request bean to populate the datatable and i insert a commandButton column
    What is a command button column and what does it do ?
    but when a push the button on the row...the page simply refresh and notinhg else
    What did you do to debug the problem ?
    when data is fetch using constants
    What does this mean ?
    Frank

  • Jsf dataTable sort

    Hi all,
    How can the contents of dataTable component be sorted, tomahawk dataTable component provides a commandSortHeader how to use this, can any one show an example on how to write the sort handler ?
    Thanks in advance

    I think that the examples should have the source. Unfortunatly don't. I've decompiled the code, and i post here what you need:
    package org.apache.myfaces.examples.listexample;
    public abstract class SortableList
    protected SortableList(String defaultSortColumn)
    _sort = defaultSortColumn;
    _ascending = isDefaultAscending(defaultSortColumn);
    protected abstract void sort(String s, boolean flag);
    protected abstract boolean isDefaultAscending(String s);
    public void sort(String sortColumn)
    if(sortColumn == null)
    throw new IllegalArgumentException("Argument sortColumn must not be null.");
    if(_sort.equals(sortColumn))
    ascending = !ascending;
    } else
    _sort = sortColumn;
    ascending = isDefaultAscending(sort);
    sort(_sort, _ascending);
    public String getSort()
    return _sort;
    public void setSort(String sort)
    _sort = sort;
    public boolean isAscending()
    return _ascending;
    public void setAscending(boolean ascending)
    _ascending = ascending;
    private String _sort;
    private boolean _ascending;
    package org.apache.myfaces.examples.listexample;
    import java.util.*;
    // Referenced classes of package org.apache.myfaces.examples.listexample:
    // SortableList, SimpleCar
    public class SimpleSortableCarList extends SortableList
    public SimpleSortableCarList()
    super("type");
    _cars = new ArrayList();
    _cars.add(new SimpleCar(1, "car A", "red"));
    _cars.add(new SimpleCar(1, "car B", "blue"));
    _cars.add(new SimpleCar(1, "car C", "green"));
    _cars.add(new SimpleCar(1, "car D", "yellow"));
    _cars.add(new SimpleCar(1, "car E", "orange"));
    public List getCars()
    sort(getSort(), isAscending());
    return _cars;
    protected boolean isDefaultAscending(String sortColumn)
    return true;
    protected void sort(final String column, final boolean ascending)
    Comparator comparator = new Comparator() {
    public int compare(Object o1, Object o2)
    SimpleCar c1 = (SimpleCar)o1;
    SimpleCar c2 = (SimpleCar)o2;
    if(column == null)
    return 0;
    if(column.equals("type"))
    return ascending ? c1.getType().compareTo(c2.getType()) : c2.getType().compareTo(c1.getType());
    if(column.equals("color"))
    return ascending ? c1.getColor().compareTo(c2.getColor()) : c2.getColor().compareTo(c1.getColor());
    else
    return 0;
    Collections.sort(_cars, comparator);
    private List _cars;
    The code was decompiled with:
    // Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://www.kpdus.com/jad.html

  • Problem with column sort in myFaces dataTable

    Hello,
    In my dataTable I am trying to do a column sort on each column, When i click on the column header link nothing is happening. Could somebody please help. Please let me know if I am missing something.
    Here is the code.
    The jsf is as follows:
    <h:panelGrid columns="1" styleClass="tableHeaderAction">
    <t:dataTable id="fooS" value="#{supervisorsDto.tableRows}"
    var="tableRow" rows"30" styleClass="dataTable"
    headerClass="tableHeader" first="0"
    columnClasses="string,string,string,string"
    rowClasses="odd,even"
    sortAscending="#{supervisorsDto.ascending}"
    sortColumn="#{supervisorsDto.sort}"
    preserveSort="true" >
    <t:column>
    <f:facet name="header">
    <t:commandSortHeader columnName="lastName" arrow="false">
    <t:outputText value="#{screen.lastName}" />
    </t:commandSortHeader>
    </f:facet>
    <t:outputText value="#{tableRow.lastName}" />
    </t:column>
    <t:column>
    <f:facet name="header">
    <t:commandSortHeader columnName="firstName" arrow="false">
    <t:outputText value="#{screen.firstName}" />
    </t:commandSortHeader>
    </f:facet>
    <t:outputText value="#{tableRow.firstName}" />
    </t:column>
    <t:column>
    <f:facet name="header">
    <t:commandSortHeader columnName="loginName" arrow="false">
    <t:outputText value="#{screen.loginName}" />
    </t:commandSortHeader>
    </f:facet>
    <t:outputText value="#{tableRow.loginName}" />
    </t:column>
    <t:column>
    <f:facet name="header">
    <t:commandSortHeader columnName="team" arrow="false">
    <t:outputText value="#{screen.team}" />
    </t:commandSortHeader>
    </f:facet>
    <t:outputText value="#{tableRow.team}" />
    <h:inputHidden id="key" value="#{tableRow.empID}" />
    </t:column>
    </t:dataTable>
    </h:panelGrid>
    The sort method in SupervisorsDto is as follows:
    public class SupervisorsDto implements Serializable {
    private String sort="lastName";
    private boolean ascending= true;
    @SuppressWarnings("unchecked")
    public void sort(final String column,final boolean ascending)
    Comparator comparator = new Comparator()
    public int compare(Object o1, Object o2)
    Supervisors c1 = (Supervisors)o1;
    Supervisors c2 = (Supervisors)o2;
    if (column == null)
    return 0;
    if (column.equals("lastName"))
    return ascending ? c1.getLastName().compareTo(c2.getLastName()) : c2.getLastName().compareTo(c1.getLastName());
    else if (column.equals("firstName"))
    return ascending ? c1.getFirstName().compareTo(c2.getFirstName()) : c2.getFirstName().compareTo(c1.getFirstName());
    else if (column.equals("loginName"))
    return ascending ? c1.getLoginName().compareTo(c2.getLoginName()) : c2.getLoginName().compareTo(c1.getLoginName());
    else if (column.equals("team"))
    return ascending ? c1.getTeam().compareTo(c2.getTeam()) : c2.getTeam().compareTo(c1.getTeam());
    else return 0;
    Collections.sort(tableRows, comparator);
    public void sort(String sortColumn)
    if (sortColumn == null)
    throw new IllegalArgumentException("Argument sortColumn must not be null.");
    if (sort.equals(sortColumn))
    //current sort equals new sortColumn -> reverse sort order
    ascending = !ascending;
    else
    //sort new column in default direction
    sort = sortColumn;
    ascending = isDefaultAscending(sort);
    sort(sort, ascending);
    protected boolean isDefaultAscending(String sortColumn)
    return true;
    public String getSort() {
    return sort;
    public void setSort(String sort) {
    this.sort = sort;
    public boolean isAscending() {
    return ascending;
    public void setAscending(boolean ascending) {
    if(ascending != this.ascending)
    this.ascending = ascending;
    Thanks!

    I think I get really good at answering my own questions.
    It seems when you select the sort option on a column you must also set the "Sort Sequence".

  • Command Link usage in JSF datatable

    Hi,
    Following is my requirement. Can any one help me in resolving the issue.
    I hava a JSF page which displays a datatable. One of the columns in the datatable displays a command link. When the user clicks the link in a particular row. Details correpsonding to the particular row have to be displayed in another page. I am using action attribute to perform the navigation from first page to next. Inside action method in the backing, is there any other means to get the row data from the datatable for which the link is clicked.
    Please help.

    You may find this article useful: http://balusc.blogspot.com/2006/06/using-datatables.html

  • Jsf datatable inside datatable component rendering problem.

    I am creating an online survey application using JSF with IceFaces component library. The survey can have any number of questions. Each question can be any one of the types checkbox, radio button, etc with multiple options.
    For this, I am using a datatable to dynamically add a question to the survey. Inside that datatable, I am using another datatable to add option to the survey.
    Now the problem is, if I keep on click on add question button, in the outer data table, question is being added without any issue. Once I click on inner data table to add a option to any of the added questions, I am able to add. But after that, if I click again on add question button, it is not working.
    This is my xhtml code:
    <ice:dataTable id="icePnlQuestionAdd" var="questAdd" value="#{createSurveyManagedBean.surveyQuestionList}">
    <ice:column>
    <table border="0" cellspacing="0" cellpadding="0">
    <tr>
    <th><ice:outputText value="Question English" style="white-space: nowrap;" /></th>                                        
    <td colspan="15">                              
    <ice:inputText id="QuestionEn" style="width:485px;" value="#{questAdd.questionEn}" />
    </td>
    </tr>
    <tr>
    <ice:dataTable id="icePnlOptionAdd" var="optionAdd" value="#{questAdd.surveyQuestionOptionList}">                               <ice:column>
    <th><ice:outputText value="Option " /></th>
    <td><ice:inputText id="OptionEn" value="#{optionAdd.optionEn}" /></td>
    </ice:column>
    </ice:dataTable>
    </tr>
    </table>
    </ice:column>
    </ice:dataTable>
    This is the add question method:
    public String addQuestion() {
    SurveyDTO addSurveyQuestionDTO = new SurveyDTO();          
    questionNum = surveyQuestionList.size();          
    addSurveyQuestionDTO.setQuestionNum(questionNum);
    surveyQuestionList.add(addSurveyQuestionDTO);
    return "createSurvey";
    This is the add option method:
    public String addOption() {
    FacesContext context = FacesContext.getCurrentInstance();          
    if (context.getExternalContext().getRequestParameterMap().get("questionNum") != null) {
    String questionNum = (String) context.getExternalContext().getRequestParameterMap().get("questionNum");
    int selectedQuestionNum = Integer.valueOf(questionNum);                    
    SurveyQuestionOptionDTO surveyQuestionOptionDTO = new SurveyQuestionOptionDTO();
    surveyQuestionList.get(selectedQuestionNum).getSurveyQuestionOptionList().add(surveyQuestionOptionDTO);
    return "createSurvey";
    }

    Bind the h:datatable in the jsp to UIDataTable component in your java code. Then when the action method is invoked, use DataTable.getWrappedObject() to get the model. Cast the model to whatever your type is (List, Array...) and then iterate through the model to process individual rows.

  • JSF datatable - any difference with JSF 1.1 and JSF 1.2

    Hi All,
    In my project there are lot of Datatables, which retrieve data from the database and display it to the user. For each datatable, the columns are not fixed. I want to create some kind of component that can be reusable.
    It is basically a JSF portlet. Now i have to use RAD 6. RAD 6 supports only JSF1.1. I have to migrate this to RAD7 in the near future. Are there any differences between the Datatable in JSF 1.1 and JSF 1.2?
    I had this approach in mind.
    a) Create the datatable programmatically and put the contents to panelgrid. This way the jsp code will be minimized. Is it a good option.? Are the APIs same in both the versions?
    b) Is it possible to create a custom datatable which can take some key as input. Then based on the key the datatable can be populated with as many columns as desired.
    Please let me know if there are any other good options.
    ~Anitha.

    Hi guys,
    my code goes like this..
    for (int j = 0; j < size; j++) {
                   UIColumn column = new UIColumn();
                   dataTable.getChildren().add(column);
                   HtmlOutputText header = new HtmlOutputText();
                   header.setValue(periodHeader[j]);
                   column.setHeader(header);
                   HtmlOutputText output = new HtmlOutputText();
                   output.setValue(new Double(periodLiability[j]));
                   ValueBinding vb1 = FacesContext.getCurrentInstance()
                             .getApplication().createValueBinding(
                                       ("#{liability.periodLiability["+j+"]}"));
                   output.setValueBinding("value", vb1);
                   column.getChildren().add(output);
    this code gives me the number of headers i need. But, it doesnt render the columns. I have an array of Double (periodLiability) which stores few values of Double type. I want to show thesee values inthe dataTable Column.
    Please help me..

Maybe you are looking for

  • Long time to load data from PSA to DSO -Sequential read RSBKDATA_V

    Hi , It is taking long time to load data from PSA to DSO. It is doing Sequential read on RSBKDATA_V and table contents no data . we are at - SAPKW70105. It started since yesterday . There is no changes in system parameters. Please advice.  Thanks Nil

  • Changing Dimensions of menu items in menubar

    I wanted to make the menu items have an auto width instead of a fixed with. So I followed the direction in the Help file under "Change dimensions of menu items" to change the .css. The menu items now seem to stretch to fit the width of the text, but

  • IPad 2 Mirroring and Airplay

    So, I upgraded to iOS 5.1 on my iPad 2 today. I tried to mirror to my HDTV via my Apple TV. I saw the little icon and selected my TV. I did not see anything but was able to hear something. Now I cannot see the icon any more. Ideas? Thanks.

  • IPOD mini not working.

    When i plug my iPOD into the USB port it reads "Itunes cannot read the contents of the iPOD "K's IPOD". Use the iPOD Software Updater application to restore the iPOD to factry settings." I dowloaded the software update and the message is still coming

  • Sybase connection tab not showing in New connection option in SQL developer

    Hi, I do not see a Sybase connection tab in New connection option in SQL developer 2.1 where as it was available in ver 1.5 Why is that? how to fix it?