Rectangle 27 3

I had a similar problem once with the dataTable exporter. You have to use an outputText like this:

<h:outputText value="#{valuesTable.tkValue}"/>

inside all the column tags, in order to see the values properly. Your column would become:

<p:column headerText="Technical Knowledge" id="tk">  
     <h:outputText value="#{valuesTable.tkValue}"/>
</p:column>

Replace all your columns and try that! Hope it helps!

And also I think the headers are not ok. You have to use an f:facet tag like this:

<p:column id="tk">
     <f:facet name="header">  
        <h:outputText value="Technical Knowledge" />  
     </f:facet>  
     <h:outputText value="#{valuesTable.tkValue}"/>
</p:column>

Now you should also see the headers in the export CSV file.

You are welcome!

jsf 2 - DataTable export is not working in Primefaces 4.0 - Stack Over...

jsf-2 primefaces
Rectangle 27 3

Your bean must implement interface Serializable. That's what the error message says

The other problem is that you always return new List by getEList. You can load your ArayList in some kind of init method that will have annotation @PostConstruct.

@PostConstruct
public void init() {
       //code from getElist()...
}

And your getter shuld be classic getter that only returns eList. In that way you load your list when your view is created. In your case every update will load list again that is bad practice. Do not fetch data in getter. Editting is not working for you because you lose updated values by returning a new list every time.

well exception rectified...but i don't get updated values, still getting the old values

yes it enters onEdit method, what i am saying is, event.getObject() method returns old object not updated one

I'va updated my answer. I haven't noticed at first that the problem was your geteList().

jsf 2 - row editing is not working in datatable primefaces - Stack Ove...

jsf-2 primefaces primefaces-extensions
Rectangle 27 3

I like to change the width using percentage in this table . But its not working.

You have syntax issues with your JSF view. Their is no bgcolor attribute of h:outputText, this is a style attribute.

<h:outputText value="#{plaza.name}" headerText="Plazas" style="bgcolor: #dcdcdc;" />

This is also true for the p:column component as well...

<p:column id="plazaName" headerText="Plaza's" style="width: 50%; bgcolor: #dcdcdc;">

And is there a way to make the checkbox of simple html style . But its a little fancy.

This would actually be quite difficult to do. The p:selectBooleanCheckbox is really a styled div with javascript events attached to it. Within this div is a hidden input type="checkbox" that exists as the form element that gets posted back. You can't do this without tinkering with javascript and stylesheets that I know of.

Wrt the checkbox, just use h:selectBooleanCheckbox. Works as good.

jsf 2 - Primefaces dataTable column width , color scheme , checkboxes ...

jsf-2 primefaces facelets
Rectangle 27 3

The first two approaches will only work if your button and the updated elements are siblings.

For the third and the fourth approach you have to traverse all containing elements in order to get the right id. You panelTableHolder is inside two other h:panelGroup (panelToRender, panelDataTable) and a div (dataTableRegion).

Furthermore to make sure that you start from highest level, prepend a : before the form id.

update=":formPesquisa:panelToRender:panelDataTable:dataTableRegion:panelTableHolder"

You could check in the rendered html if this is the correct path for your panelTableHolder.

Thansk for the quick reply! So...i did see the rendered html, and the id of the dataTableHolder is formPesquisa:panelTableHolder. But even if i put like this, it doesn't work. Do you think it might have something to do with the fact that at first the panelDataTable is not rendered?

Did you try update="@form"? Furthermore you need h:head instead of head in order to include the js libs for ajax.

datatable - JSF 2 + Primefaces - Update Not Working - Stack Overflow

jsf datatable primefaces
Rectangle 27 2

Instead of using update attribute on the p:commandButton, I update a row from the action method. Now the pagination doesn't seem to break. There are two option then and I used first one.

Solution used in p:commandButton attribute action is as follows,

Use a plain PrimeFaces solution to in the form of the Search Expression Framework documentation and showcase

public void updateRow(UIData table) {
    int index = table.getRowIndex();
    RequestContext.update(table.getClientId() + ":@row(" + index + ")");
}

jsf 2 - Primefaces datatable pagination not working after an update - ...

jsf-2 primefaces
Rectangle 27 5

Do you have your p:dataTable wrapped in a h:form tag? This actually works for me:

package com.mycompany;

import java.util.Arrays;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import org.primefaces.event.SelectEvent;

@ManagedBean
@ViewScoped
public class NotificationBox {

    public class NotificationForm {

        Integer notificationId;

        String name;

        public NotificationForm(Integer id, String nam) {
            notificationId = id;
            name = nam;
        }

        public String getName() {
            return name;
        }

        public Integer getNotificationId() {
            return notificationId;
        }

        @Override
        public String toString() {
            return "NotificationForm [notificationId=" + notificationId
                    + ", name=" + name + "]";
        }
    }

    private List<NotificationForm> notificationsList;

    public NotificationForm notification;

    public NotificationBox() {
        notificationsList = Arrays.asList(new NotificationForm(1, "Form1"),
                new NotificationForm(2, "Form2"));
    }

    public NotificationForm getNotification() {
        return notification;
    }

    public List<NotificationForm> getNotificationsList() {
        return notificationsList;
    }

    public void onRowSelect(SelectEvent event) {
        System.out.println(event.getObject());
    }

    public void setNotification(NotificationForm notification) {
        this.notification = notification;
    }

}
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
</h:head>

<h:body>

    <h:form>
        <p:dataTable id="db" value="#{notificationBox.notificationsList}"
            var="notificationForm" rows="15"
            emptyMessage="${msgs.getMessage('table.empty.message')}"
            paginator="true" paginatorPosition="bottom"
            rowKey="#{notificationForm.notificationId}"
            selection="#{notificationBox.notification}"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} ( ${notificationBox.notificationsList.size()} ${msgs.getMessage('table.records')} )"
            selectionMode="single" tableStyle="height:430px">

            <p:ajax event="rowSelect" listener="#{notificationBox.onRowSelect}" />

            <p:column>
        #{notificationForm.name}
        </p:column>
        </p:dataTable>
    </h:form>
</h:body>
</html>

jsf - DataTable row Selection not working - Stack Overflow

jsf jsf-2 primefaces
Rectangle 27 5

Do you have your p:dataTable wrapped in a h:form tag? This actually works for me:

package com.mycompany;

import java.util.Arrays;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import org.primefaces.event.SelectEvent;

@ManagedBean
@ViewScoped
public class NotificationBox {

    public class NotificationForm {

        Integer notificationId;

        String name;

        public NotificationForm(Integer id, String nam) {
            notificationId = id;
            name = nam;
        }

        public String getName() {
            return name;
        }

        public Integer getNotificationId() {
            return notificationId;
        }

        @Override
        public String toString() {
            return "NotificationForm [notificationId=" + notificationId
                    + ", name=" + name + "]";
        }
    }

    private List<NotificationForm> notificationsList;

    public NotificationForm notification;

    public NotificationBox() {
        notificationsList = Arrays.asList(new NotificationForm(1, "Form1"),
                new NotificationForm(2, "Form2"));
    }

    public NotificationForm getNotification() {
        return notification;
    }

    public List<NotificationForm> getNotificationsList() {
        return notificationsList;
    }

    public void onRowSelect(SelectEvent event) {
        System.out.println(event.getObject());
    }

    public void setNotification(NotificationForm notification) {
        this.notification = notification;
    }

}
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
</h:head>

<h:body>

    <h:form>
        <p:dataTable id="db" value="#{notificationBox.notificationsList}"
            var="notificationForm" rows="15"
            emptyMessage="${msgs.getMessage('table.empty.message')}"
            paginator="true" paginatorPosition="bottom"
            rowKey="#{notificationForm.notificationId}"
            selection="#{notificationBox.notification}"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} ( ${notificationBox.notificationsList.size()} ${msgs.getMessage('table.records')} )"
            selectionMode="single" tableStyle="height:430px">

            <p:ajax event="rowSelect" listener="#{notificationBox.onRowSelect}" />

            <p:column>
        #{notificationForm.name}
        </p:column>
        </p:dataTable>
    </h:form>
</h:body>
</html>

jsf - DataTable row Selection not working - Stack Overflow

jsf jsf-2 primefaces
Rectangle 27 3

After playing with Primeface, I am now able to resolve the issue. Sharing the solution so that it can help others if required. commonDataTable.xhtml:

<ui:component xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:cc="http://java.sun.com/jsf/composite"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:p="http://primefaces.org/ui">

    <cc:interface>
        <cc:attribute name="rows" />
        <cc:attribute name="value"
            type="org.primefaces.model.LazyDataModel" />
        <cc:attribute name="var" />
        <cc:attribute name="id" />
        <cc:attribute name="rowStyle" />
    </cc:interface>

    <cc:implementation>
        <p:dataTable value="#{cc.attrs.value}"
            rendered="#{not empty cc.attrs.value}" id="#{cc.attrs.id}"
            paginator="true" rows="25" 
            currentPageReportTemplate="Showing {startRecord}-{endRecord} of     {totalRecords}"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
            rowsPerPageTemplate="25,50,100" paginatorPosition="bottom"
            lazy="true" rowStyleClass="#{cc.attrs.rowStyle}">
             <c:set target="#{component}" property="var" value="#{cc.attrs.var}"/>
            <cc:insertChildren />
        </p:dataTable>
    </cc:implementation>
    </ui:component>
<ui:composition template="/WEB-INF/template/layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:t="http://java.sun.com/jsf/composite/components">

<ui:param name="pageTitle" value="My Page" />

<ui:define name="content">
  <p:fieldset>
     <h2>employee Overview</h2>

     <h:form>
        <p:messages id="messages" showDetail="true" autoUpdate="true"
           closable="true" />
        <p:panel rendered="#{not empty mySummaryBean.employeeRunModel}">
           <t:commonDataTable var="employee" value="#{mySummaryBean.employeeRunModel}" rows="10"
                             id="employeeTable"
                             rowStyle="#{employee.employeeErrorStatus}">

                     .........
           </t:commonDataTable>
        </p:panel>
     </h:form>
  </p:fieldset>
</ui:define>
</ui:composition>

jsf - DataTable as Composite Component with LazyDataModel Not Working ...

jsf jsf-2 primefaces datatable composite-component
Rectangle 27 3

For some reason, this was not working

<p:column headerText="" width="25" sortBy="#{row.key}">

(Still valid:) In Primefaces 6.1 attribute width without a unit means px, with unit % it means percentage of table width.

css - How to set width of a p:column in a p:dataTable in PrimeFaces 3....

css jsf jsf-2 primefaces datatable
Rectangle 27 1

If you are making it request scoped, then you are telling JSF to throw out all of your existing data every time the user is done talking to your server. So it makes no sense to have JSF run a listener on an existing page. In particular, PrimeFaces has a tendency to malfunction when it encounters an odd set of scopes.

I thought about this but if i got to this way i would need to implement view scope for spring managed beans. But i want to avoid this. On the other hand i have another page similar to this one and it works perfectly fine with request scope bean.

There really isn't a good way around it. You should be able to call another bean which is session (or application) scoped, but you would be trying to fit a square peg into a round hole. If you run an ajax event on a request-scoped bean, then the only way the event will get called is if it creates an entirely new bean, meaning you can't reference any of your data. And calling a row select event on empty data doesn't make any sense.

yes, you are correct. if i put my customer ID in bean constructor(for the sake of testing), the instant row selection works as it knows how to reload the table again. So i'm a bit confused? Why would it need to reload table again in order to make selection?

Because that's how you told it to behave when you said it was request-scoped. :) If you make something request-scoped, the server-side code will immediately delete any information it has as soon as it's done with each separate HTTP request. Try looking at this flow: - User makes request to load the page (HTTP request) - Server is done with HTTP request, so it deletes the bean - User selects a row. This creates an AJAX request. - Server creates a new bean to deal with the request. This bean doesn't have any of the information from the first bean.

Ok, i see. Thanks for clearing some stuff for me. I'm still learning all this stuff. Is there anyway how i can pass param with my table, so that when new request is executed on row selection it will also include(in my case) customer id?

jsf 2 - Primefaces dataTable instant Row Selection not working - Stack...

jsf-2 primefaces
Rectangle 27 1

You are using both the value and the valueChangeListener attributes of the drop down component. Why would you do this?

value="#{reqSummaryHandler.certNumber}
setCertNumber(String certNumber)

thanks maple_shaft... but I need to refresh the p:datatable when the dropdown values changes , so that that I can update the column values.Then how would I refresh the datatable if I am not using valuechangelistener.

setCertNumber
certActListModel.getRowData().setRoutePathCd(newValue);

I tried adding the same line mentioned , but once the screen loads for the first time,and I change the value in dropdown ,changed value appears as "A" in column even though I have selected "B". This works for the first time ,but if I change the dropdown value again , it is not changing in the table.While debugging I am getting this exceptoin - javax.faces.model.NoRowAvailableException

jsf 2 - Dropdown's valueChangeListener not working with primefaces dat...

jsf-2 primefaces
Rectangle 27 1

<p:ajax event="rowEdit" listener="#{employees.onEdit}"
            update=":form:messages" />

you only update messagess and not datatable itself. Try this: update=":form:messages, :form:elist1". That works for me

I changed code as <p:ajax event="rowEdit" listener="#{employees.onEdit}" update=":form:messages,:form:elist1" /> <p:ajax event="rowEditCancel" listener="#{employees.onCancel}" update=":form:messages,:form:elist1" /> but no change

What scope you use? Is it view scoped bean? Have you done debugging? Do you enter this method or not?

i am using request scope. i updated the datatable component, with your code, but still it is not working..

Why do you use request scope instead of view scope? Do you have specific reason? This update that I suggested have no meaning in request scope.

I changed the scope to view..but exception is there. i paste the exception and my managed bean in my question

jsf 2 - row editing is not working in datatable primefaces - Stack Ove...

jsf-2 primefaces primefaces-extensions
Rectangle 27 1

If you are making it request scoped, then you are telling JSF to throw out all of your existing data every time the user is done talking to your server. So it makes no sense to have JSF run a listener on an existing page. In particular, PrimeFaces has a tendency to malfunction when it encounters an odd set of scopes.

I thought about this but if i got to this way i would need to implement view scope for spring managed beans. But i want to avoid this. On the other hand i have another page similar to this one and it works perfectly fine with request scope bean.

There really isn't a good way around it. You should be able to call another bean which is session (or application) scoped, but you would be trying to fit a square peg into a round hole. If you run an ajax event on a request-scoped bean, then the only way the event will get called is if it creates an entirely new bean, meaning you can't reference any of your data. And calling a row select event on empty data doesn't make any sense.

yes, you are correct. if i put my customer ID in bean constructor(for the sake of testing), the instant row selection works as it knows how to reload the table again. So i'm a bit confused? Why would it need to reload table again in order to make selection?

Because that's how you told it to behave when you said it was request-scoped. :) If you make something request-scoped, the server-side code will immediately delete any information it has as soon as it's done with each separate HTTP request. Try looking at this flow: - User makes request to load the page (HTTP request) - Server is done with HTTP request, so it deletes the bean - User selects a row. This creates an AJAX request. - Server creates a new bean to deal with the request. This bean doesn't have any of the information from the first bean.

Ok, i see. Thanks for clearing some stuff for me. I'm still learning all this stuff. Is there anyway how i can pass param with my table, so that when new request is executed on row selection it will also include(in my case) customer id?

jsf 2 - Primefaces dataTable instant Row Selection not working - Stack...

jsf-2 primefaces
Rectangle 27 4

Having the curly braces being removed is out-dated (for older versions). It has been unified to EL code.

With latest PF 6.0, I had to add the context parameter javax.faces.STATE_SAVING_METHOD to client in my web.xml. Else I would get the famous "view cannot be restored" message and sorting is not working then. Also changing scoped from request to view and session didn't help (I tried them).

jsf - PrimeFaces dataTable sorting not working - Stack Overflow

jsf sorting primefaces datatable
Rectangle 27 2

First of all, the proper attribute values of the required attribute are the boolean values true or false, not a string value of Yes. It's an attribute which accepts a boolean expression.

The following are proper usage examples:

<h:inputText required="true" />
<h:inputText required="#{bean.booleanValue}" />
<h:inputText required="#{bean.stringValue == 'Yes'}" />

As to the problem that it doesn't work inside a <h:dataTable>, that can happen when the datamodel is not been preserved properly (the datamodel is whatever the table retrieves in its value attribute). That can in turn happen when the managed bean is request scoped and doesn't prepare the datamodel during its (post)construction which causes that the datamodel is null or empty while JSF is about to gather, convert and validate the submitted values.

You need to ensure that the datamodel is exactly the same during the apply request values phase of the form submit request as it was during the render response phase of the initial request to display the form with the table. An easy quick test is to put the bean in the session scope. If that fixes the problem, then you definitely need to rewrite the datamodel preserving logic. You could also use Tomahawk's <t:saveState> or <t:dataTable preserveDataModel="true"> to store the datamodel in the view scope (like as JSF2's new view scope is doing).

I apologize for the version and the request boolean. In fact, our bean is in session scope. I think I got what you are saying but the bean is in session scope and it is still not working. Thanks for the response. If you can think any other things that is affecting the validation let me know as I am not very familiar with JSF.

To be sure, the table with the input is inside a <h:form>, right? And you don't do the data loading job in the getter method of the datatable value, right?

Yes, it is under form. I forgot to mention that I am using icefaces 1.7. So it is under <ice:form><ice:panelGroup><ice:panelGrid><ice:dataTable> . I don't it is something with icefaces but a task as simple as this should not have been an issue?

well thanks for the comments I had there were some mistakes in the ids. I was using the same id for form and datatable.

java ee - JSF Required=Yes not working inside a datatable? - Stack Ove...

jsf java-ee validation customvalidator requiredfieldvalidator
Rectangle 27 3

INMO selection should point to an array instead of array list

listBEean
private LocationEBean[] listBEeans;

@Danial,Thanks for the suggestion,but still the list value is null ,is any property i missed out ?

not sure what you mean.... take a look at the showcase (posted link in my answer)

Thanks @Danial,it's working now,some thing went wrong with my server site.

You are welcome.

jsf - primefaces 3.3.1 datatable multiple selection is not working - S...

jsf datatable primefaces
Rectangle 27 2

<p:dataTable id="table" value="#{myBean.users}" var="usr" rowKey="#{usr.username}" widgetVar="usrwv">
        <f:facet name="header">  
            <p:outputPanel>  
                 <h:outputText value="Search all fields:" />  
                 <p:inputText id="globalFilter" onkeyup="usrwv.filter()" style="width:150px" />  
            </p:outputPanel>  
        </f:facet>
        <p:column headerText="Username" sortBy="#{usr.username}" filterBy="#{usr.username}">
               <f:facet name="header">  
                     Username
               </f:facet>
               <h:outputText value="#{usr.username}"/>
        </p:column>
        <p:column headerText="Role" sortBy="#{usr.role}" filterBy="#{usr.role}">
                <f:facet name="header">  
                     Role
                </f:facet>
                <h:outputText value="#{usr.role}"/>
        </p:column>
        <f:facet name="footer">
                <h:commandLink>  
                     <p:graphicImage value="/resources/images/excel.ico" title="myExcel"/>
                     <p:dataExporter type="csv" target="table" fileName="all_users"/>  
                </h:commandLink>
        </f:facet>
</p:dataTable>

Also you are putting the exporter and the datatable in two different forms. Try putting them in the same form. This should work.

Thanks Fareed !! By putting DataTable and DataExporter in a single form I have got the desired result :)

jsf - DataExporter not working for filtered dataTable in Primefaces 3....

jsf
Rectangle 27 3

What i Undestand from your question is you want create an Editable DataTable. As you are using dataTable attribute selectionMode="Single" which seems everything right for me. I cant say what went wrong with it as it involved many other complexities. But you can achieve the samething (populating selectedCustomer In Backing bean)

rowEditListener="#{customerBean.listenerInBackingBean}"
public void listenerInBackingBean(org.primefaces.event.RowEditEvent ev) {

        Customer selectedCustomer  = (Customer) ev.getObject();
        //write Logic to Store Customer in Database

}
<p:commandButton >
  <f:setPropertyActionListener value="#{customer}" target="#{customerBean.selectedCustomer}" />
 </p:commandButton>

Here selectedCustomer is instance of type Customer.

jsf - Primefaces DataTable filtering and RowSelection not working - St...

jsf primefaces managed-bean
Rectangle 27 3

You can always give width= "X" to your <p:column> or <p:columns>. It works when the datatable is scrollable. As follows,

<p:column selectionMode="multiple" width="15" />

<p:columns width="150" value="..." var="..." columnIndexVar="..." sortBy="..." filterBy="..." >
javax.faces.FacesException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled.

Do you want to use selection? If not, do not use "selectionMode". If you do, did you try adding a "rowKey" to your datatable? You may want to check this: stackoverflow.com/questions/12333764/

jsf - Primefaces datatable scrolling not working as hoped - Stack Over...

jsf jsf-2 primefaces
Rectangle 27 2

It look like that you're abusing preRenderView to initialize the state of a view scoped bean. However, as its name says, it runs right before the rendering of the view. You should instead be using the @PostConstruct annotation for that. When put on a method, then that method will be invoked after bean's construction and all managed property and dependency injection. It will not be invoked on all subsequent postback requests on the same view.

@PostConstruct
public void initialize() {
    resultList = Database.executeSelect(database);
}
<f:event>

jsf - updating datatable using AJAX not working - Stack Overflow

ajax jsf primefaces datatable