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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:38:38+00:00 2026-06-01T06:38:38+00:00

I have this JSF table which is used to display data. I want to

  • 0

I have this JSF table which is used to display data. I want to use AJAX to update the rows of the table.

<?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:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      >
    <h:head>
        <h:outputStylesheet library="css" name="table-style.css"  />
    </h:head>
    <h:body>

        <h1>JSF 2 dataTable example</h1>
        <h:form>
            <h:dataTable id="ajaxtable" 
                        value="#{order.orderModel}" var="o"
                styleClass="order-table"
                headerClass="order-table-header"
                rowClasses="order-table-odd-row,order-table-even-row">

                        <h:column>

                    <f:facet name="header">No</f:facet>

                    <h:inputText rendered="false"/>

                    <h:outputText value="#{order.orderModel.rowIndex + 1}"  />

                </h:column>
                <h:column>

                    <f:facet name="header">Order No</f:facet>

                    <h:inputText value="#{o.orderNo}" size="10" rendered="#{o.editable}" />

                    <h:outputText value="#{o.orderNo}" rendered="#{not o.editable}" />

                </h:column>

                <h:column>

                    <f:facet name="header">Product Name</f:facet>

                    <h:inputText value="#{o.productName}" size="20" rendered="#{o.editable}" />

                    <h:outputText value="#{o.productName}" rendered="#{not o.editable}" />

                </h:column>

                <h:column>

                    <f:facet name="header">Price</f:facet>

                    <h:inputText value="#{o.price}" size="10" rendered="#{o.editable}" />

                    <h:outputText value="#{o.price}" rendered="#{not o.editable}" />

                </h:column>

                <h:column>

                    <f:facet name="header">Quantity</f:facet>

                    <h:inputText value="#{o.qty}" size="5" rendered="#{o.editable}" />

                    <h:outputText value="#{o.qty}" rendered="#{not o.editable}" />

                </h:column>

                <h:column>

                    <f:facet name="header">Action</f:facet>

                    <h:commandLink id="editlink" value="Edit" action="#{order.editAction(o)}" rendered="#{not o.editable}">
                                    <f:ajax execute="@this" render="editlink"/>
                                </h:commandLink>

                </h:column>

            </h:dataTable>

            <h:commandButton value="Save Changes" action="#{order.saveAction}">
                    <f:ajax execute="@this" render="ajaxtable"/>
                </h:commandButton>


        </h:form>
    </h:body>

</html>

When I pres this button(link) the row of the table is not updated.

    <h:commandLink id="editlink" value="Edit" action="#{order.editAction(o)}" rendered="#{not o.editable}">
          <f:ajax execute="@this" render="editlink"/>
    </h:commandLink>

I suspect that AJAX cannot be used when I have links.

And the second problem is this:

            <h:column>

                <f:facet name="header">No</f:facet>

                <h:inputText rendered="false"/>

                <h:outputText value="#{order.orderModel.rowIndex + 1}"  />

            </h:column>

If I remove inputText I get this error: Index: 0, Size: 0. Should I left this?

Best wishes

  • 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-01T06:38:39+00:00Added an answer on June 1, 2026 at 6:38 am

    The mistake is in the render attribute of the ajax link in question:

    <h:commandLink id="editlink" ...>
        <f:ajax execute="@this" render="editlink" />
    </h:commandLink>
    

    You’re telling it to render only the edit link itself. You’re basically doing the same as render="@this". You are not telling it to render the table. You need to tell it to render the table.

    First give the <h:form> a fixed id so that you can specify a fixed client ID later in the render.

    <h:form id="form">
    

    Then fix the ajax link as follows to tell it to render the table:

    <h:commandLink id="editlink" ...>
        <f:ajax execute="@this" render=":form:ajaxtable" />
    </h:commandLink>
    

    An alternative is to bind the table to the view so that you can get its client ID dynamically:

    <h:dataTable binding="#{table}" ...>
    

    with

    <h:commandLink id="editlink" ...>
        <f:ajax execute="@this" render=":#{table.clientId}" />
    </h:commandLink>
    

    (this way you can also show row number by #{table.rowIndex} without the need for a DataModel)

    See also:

    • Communication in JSF 2.0
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this JSF table. I want to add row numbers. <?xml version=1.0 encoding=UTF-8?>
I have this form which can insert/update values into database table. <div id=settingsdiv style=width:350px;
I would like to create table which can display data from database into JSF
I have a dynamic data table in JSF which has multiple input elements which
I have the following JSF table: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE html PUBLIC -//W3C//DTD XHTML
I have a table in a database which is used for storing application configuration
I have a simple data table which contains dynamic form text fields. Each field
I have this simple code in facelets numbers.xhtml: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html
I have JSF code like: <h:inputText id=from value=#{fromToMBean.fromName}/> I would like to get this
I have this code in jQuery, that I want to reimplement with the prototype

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.