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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:20:26+00:00 2026-05-18T01:20:26+00:00

First time using JSF, and I’m sort of confused about how getRowData() works. All

  • 0

First time using JSF, and I’m sort of confused about how getRowData() works. All I found while searching around the internet is that it returns the “currently selected row” in a data table, but I couldn’t find out how it decides which row is the selected one. For example, I have this code for a data table:

JSP:

  <h:dataTable value="#{backing_student.eligibleCoursesList}" var="cdto"
                     binding="#{backing_student.eligibleCoursesDataTable}"
                     id="eligibleCoursesDataTable" rules="all" frame="box"
                     border="2">
  <%-- 
            oracle-jdev-comment:Faces.RI.DT.Class.Key:hu.elte.pgy2.BACNAAI.UranEJB.CourseDTO
          --%>
    <h:column>
      <f:facet name="header">
        <h:outputText value="Kurzuskód"
                      binding="#{backing_student.outputText7}"
                      id="outputText7"/>
      </f:facet>
      <h:outputText value="#{cdto.cid}"/>
    </h:column>
    <!-- couple more plain text columns like the above -->
    </h:column>
    <h:column>
      <h:commandButton value="Felvétel"
                       actionListener="#{backing_student.addSelfToCourseListener}"/>
    </h:column>
  </h:dataTable>

Backing bean:

public class BackingStudent {
    private HtmlDataTable eligibleCoursesDataTable;
    private List<CourseDTO> eligibleCoursesList;

    // ...

    public void addSelfToCourseListener(ActionEvent actionEvent) {
        HtmlCommandButton thisButton = (HtmlCommandButton)actionEvent.getComponent();
        CourseDTO cdto = (CourseDTO)(eligibleCoursesDataTable.getRowData());
        thisButton.setValue(cdto.getCid());
    }
}

This makes it so that whenever I click the button in whichever row, the text of all buttons changes to the value in the first column of that row. How exactly does getRowData() know which row to fetch from the table?

Bonus question: why does every button’s text change?

  • 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-05-18T01:20:27+00:00Added an answer on May 18, 2026 at 1:20 am

    The JSF tags cause a component tree to be built in memory. For example, the dataTable tag is backed by a UIData instance (of which HtmlDataTable is a subclass). The role of UIData is to iterate over a DataModel. For each phase of the JSF lifecycle, it will do something like this:

    //not the real code
    for(int i=0; i<model.getRowCount(); i++) {
      model.setRowIndex(i);
      Object row = model.getRowData();
      externalContext.getRequestMap().put(var, row);
      //invoke phase-specific action
      externalContext.getRequestMap().remove(var);
    }
    

    In your case, the var="cdto", which is why any controls that use EL to resolve to the row bean will get the correct value.

    When the component tree is built, UIData does not add another child control per row. It uses one set of controls and changes the underlying model data. Although the UIData performs some actions to preserve child state, it will not do so (by default) for instances of HtmlCommandButton because it does not implement EditableValueHolder.

    To fix this issue, use an EL expression to bind the value to your model (probably some row bean property).

    Note: you can generally avoid having to write code where you have to import any javax.faces... classes into your model beans, but you have to put a bit of thought into your model design.

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

Sidebar

Related Questions

Problem on WindowsXP (likely will happen on all Win installs), first time using Mercurial.
First time using jQuery parent and got confused, here's my html: <div id=friends_inveni class=friends_rec
my first time using one of these and I'm pretty sure this works as
First time using Asp.net-mvc and originally followed the NerdDinner tutorial. My form submit button
this is my first time using StAX for parsing XML documents (still in the
I want to deploy a website the first time using Rails 3.2.1 with capistrano
I'm writing a facebook desktop application for the first time using the PyFacebook api.
I'm currently trying to access a REST API for the first time using visual
Sorry, this is my first time using this forum. Apparently people can edit my
Creating a simple RPG game, first time using XNA. Trying to get my character

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.