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 8178189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:42:10+00:00 2026-06-06T23:42:10+00:00

I have a dataTable. The data of the dataTable is filled via ajax. A

  • 0

I have a dataTable. The data of the dataTable is filled via ajax. A row of the table contains among other things form elements like a button. The button in the datatTable should refer to another page but if I click on them the current page is reloaded.

Here some code:

the backing bean:

@ManagedBean(name="bean")
@SessionScoped
public class Bean {

private List<String> data;

@PostConstruct
public void postConstruct() {
    data = new ArrayList<String>();

}

public void fillTable() {
    data.add("E1");
    data.add("E2");
    data.add("E3");
}

public String outcome(){
    return "/faces/test/edit.jsf";
}

public List<String> getData() {
    return data;
}

public void setData(List<String> data) {
    this.data = data;
}

}

the page:

 <!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" >
<h:body>
<h:form id="form">
<h:commandButton value="fillTable">
    <f:ajax listener="#{bean.fillTable()}" render="@form"/>
</h:commandButton>
<h:dataTable id="table" var="data" value="#{bean.data}">
    <h:column>
        <h:outputText value="#{data}" />
    </h:column>
    <h:column>
        <h:commandButton value="edit" action="#{bean.outcome}" />
    </h:column>
</h:dataTable>
</h:form>
</h:body>
</html>

I know that this has something to do that the form is already in the dom and the button are lazy loaded into the page (if someone could be more specific I would be very pleased).

Although if I change the Scope of the backing bean to SessionScope it works. The button redirect to the right page. Why?

  • 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-06T23:42:11+00:00Added an answer on June 6, 2026 at 11:42 pm

    Although if I change the Scope of the backing bean to SessionScope it works. The button redirect to the right page

    The bean should have been placed in the view scope. The session scope is too broad and would only risk unintuitive behaviour when the same view is been opened in multiple browser windows/tabs in the same session.

    The explanation is as follows: when a form is submitted, JSF needs to identify the command button pressed in order to invoke the associated action method. As the command button is been placed in side a datatable, JSF needs to iterate over its datamodel first. But if the datamodel has been changed, or is empty, then JSF won’t be able to identify the command button. Hence the action won’t be invoked.

    When the bean is in the request scope, then it will be trashed by end of response and recreated during every new request, including ajax requests. All of the bean’s properties will obviously get the default values again, so also the data property in your case.

    See also:

    • commandButton/commandLink/ajax action/listener method not invoked or input value not updated – particularly point #4.
    • How to choose the right bean scope?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data table filled with text in each table row. How do
I have a datatable which contains yearly data saved. e.g. dtDate Value 2010-01-01 00:00:00.000
I have a datatable that contains rows of transaction data for multiple users. Each
Importing a spreadsheet I have filled a DataTable object with that data and returns
I have a non-editable DataTable built with PrimeFaces. The table is initially filled with
I have a datatable with a bunch of fields, and it's filled data by
I have PrimeFaces dataTable that is been filled by a Ajax call. When I
I have a data table whose defaultview.sort is already set, and the datatable is
I have a datatable which contains following data as SrNo Roll Name 1 1
I have two DataTable [System.Data] .One contains three rows id,name,date and another contains id

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.