Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8970499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:44:07+00:00 2026-06-15T17:44:07+00:00

I have simple JSF page and simple backing bean. I have p:commandButton on the

  • 0

I have simple JSF page and simple backing bean. I have p:commandButton on the page and p:datatable. With commandButton I need to update dataTable with ajax, but it does not happens. What could be the reason?

Here is the page:

<ui:define name="content">
        <h2>#{menu['management.roles.perms']}</h2>

        <h:form id="form">
            <p:fieldset style="border: 0px" toggleable="false" collapsed="false">
                <p:tabView>
                    <p:tab title="#{messages['roles']}">
                         <p:dataTable id="dataTable" value="#{rolesBean.roles}" var="role"
                                      editable="true" rows="10" rowKey="#{role.id}">

                             <p:ajax event="rowEdit" listener="#{rolesBean.onEdit}"/>
                             <f:facet name="footer">
                                 <p:commandButton value="#{misc['add.role']}"
                                                  actionListener="#{rolesBean.addRole}" update="dataTable"/>
                             </f:facet>
                             <p:column headerText="#{misc['name.database']}">
                                 <p:cellEditor>
                                     <f:facet name="output">
                                         <h:outputText value="#{role.name}"/>
                                     </f:facet>
                                     <f:facet name="input">
                                         <h:inputText value="#{role.name}"/>
                                     </f:facet>
                                 </p:cellEditor>
                             </p:column>

                             <p:column headerText="#{misc['date']}">
                                 <f:facet name="output">
                                     <h:outputText value="#{role.creationDate}">
                                         <f:convertDateTime pattern="dd.MM.yyyy" />
                                     </h:outputText>
                                 </f:facet>
                             </p:column>

                             <p:column headerText="#{misc['description']}">
                                 <p:cellEditor>
                                     <f:facet name="output">
                                         <h:outputText value="#{role.description}"/>
                                     </f:facet>
                                     <f:facet name="input">
                                         <h:inputText value="#{role.description}"/>
                                     </f:facet>
                                 </p:cellEditor>
                             </p:column>

                             <p:column headerText="#{messages['edit']}">
                                 <p:rowEditor />
                             </p:column>
                         </p:dataTable>
                    </p:tab>

                    <p:tab title="#{messages['perms']}">

                    </p:tab>

                    <p:tab title="#{clients['history']}">
                    </p:tab>
                </p:tabView>
            </p:fieldset>
        </h:form>
    </ui:define>

And here is the code of backingBean:

@ViewScoped
@ManagedBean(name = "rolesBean")
public class RolesViewBean extends BasicViewBean<Role> {

    private static final long serialVersionUID = 27377603187254821L;
    @Inject
    RoleDao dao;
    private List<Role> roles;

    @Override
    protected BasicDao<Role> getDAO() {
        return dao;
    }

    public void onEdit(RowEditEvent event){
        this.entity = (Role) event.getObject();
        dao.update(this.entity);
    }

    public void addRole(){
        roles.add(new Role());
    }

    public List<Role> getRoles() {
        roles = dao.getRoleList();
        return roles;
    }

    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:44:07+00:00Added an answer on June 15, 2026 at 5:44 pm

    At first glance, the problem is that your addRole method modifes the “roles” list, while the getRoles (which gets called by the dataTable) resets it to whatever is saved in the database.
    So your datatabe gets updated, it’ just that it gets updated with the same values.

    Think about that 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple JSF application. Everything works fine, but not navigation. It behaves like
Ok simple question. I have a JSF application, containing a login page. The problem
I have a simple problem on .xhtml page. This expression is not working :-
i have this simple page: <h:form id=form> <p:dataTable value=#{testBean.unitTypeModel} var=elem lazy=true rows=10> <p:column headerText=class>#{elem.class.simpleName}</p:column>
In my JSF 1.2 webapp I have a page with a <h:commandButton> that invokes
I have what I thought was simple JSF navigation setup but when I hit
i have a pretty simple jsf page with three selectOneRadio components. two of them
I have a simple Login page made with JSF 2.0. Usually in every login
I have simple jsf page with view params and load method which is processing
On my JSF page I'm displaying a simple database table in a dataTable .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.