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

  • Home
  • SEARCH
  • 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 3312052
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:56:55+00:00 2026-05-17T21:56:55+00:00

I have a page that lists all from my Post table, it looks like

  • 0

I have a page that lists all from my Post table, it looks like this:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>TODO supply a title</title>
</head>
<body>
    <p>
        <h:dataTable id="grid1" value="#{postControle.lista}" var="post1">
            <h:column>
                <f:facet name="header"><h:outputText style="float: left; font-weight: bold;" value="Titulo"/></f:facet>
                #{post1.titulo}
            </h:column>
            <h:column>
                <f:facet name="header"><h:outputText style="float: left; font-weight: bold;" value="Texto"/></f:facet>
                #{post1.texto}
            </h:column>
            <h:column>
                <f:facet name="header"><h:outputText style="float: left; font-weight: bold;" value="Opções"/></f:facet>
                <a href="#{postControle.requestManager('alterar',post1.id)}">Alterar</a> |
                <a href="#{postControle.requestManager('consultar',post1.id)}">Consultar</a>
            </h:column>
        </h:dataTable>
    </p>
</body>

What i want is that, at the end of each line, 2 links, one for update and other for show actions get the id of that specific post, but as it is its setting every id as the last resault of the list. How can i fix that?

Edit: Heres the HTML generated:

<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <title>TODO supply a title</title> 
</head> 
<body> 
    <p><table id="grid1"> 
            <thead> 
                <tr> 
                    <th scope="col"><span style="float: left; font-weight: bold;">Titulo</span></th> 
                    <th scope="col"><span style="float: left; font-weight: bold;">Texto</span></th> 
                    <th scope="col"><span style="float: left; font-weight: bold;">Opções</span></th> 
                </tr> 
            </thead> 
            <tbody> 
                <tr> 
                    <td> 
                        testeZ
                    </td> 
                    <td> 
                        testeZ
                    </td> 
                    <td><a href="./faces/alterar.xhtml">Alterar</a> |
                        <a href="./faces/consultar.xhtml">Consultar</a></td> 
                </tr> 
                <tr> 
                    <td> 
                        testeZ
                    </td> 
                    <td> 
                        testeZ
                    </td> 
                    <td><a href="./faces/alterar.xhtml">Alterar</a> |
                        <a href="./faces/consultar.xhtml">Consultar</a></td> 
                </tr> 
                <tr> 
                    <td> 
                        testeZ
                    </td> 
                    <td> 
                        testeZ
                    </td> 
                    <td><a href="./faces/alterar.xhtml">Alterar</a> |
                        <a href="./faces/consultar.xhtml">Consultar</a></td> 
                </tr> 
                <tr> 
                    <td> 
                        asdasdsa
                    </td> 
                    <td> 
                        asdsadsad
                    </td> 
                    <td><a href="./faces/alterar.xhtml">Alterar</a> |
                        <a href="./faces/consultar.xhtml">Consultar</a></td> 
                </tr> 
                <tr> 
                    <td> 
                        ddddd
                    </td> 
                    <td> 
                        dddd
                    </td> 
                    <td><a href="./faces/alterar.xhtml">Alterar</a> |
                        <a href="./faces/consultar.xhtml">Consultar</a></td> 
                </tr> 
                <tr> 
                    <td>                     
                    </td> 
                    <td>                     
                    </td> 
                    <td><a href="./faces/alterar.xhtml">Alterar</a> |
                        <a href="./faces/consultar.xhtml">Consultar</a></td> 
                </tr> 
                <tr> 
                    <td>                     
                    </td> 
                    <td>                    
                    </td> 
                    <td><a href="./faces/alterar.xhtml">Alterar</a> |
                        <a href="./faces/consultar.xhtml">Consultar</a></td> 
                </tr> 
                <tr> 
                    <td> 
                        dsakhgdsail
                    </td> 
                    <td> 
                        woaiuheaoiusrhjgsohrspuiohpousrhpiojnojho
                    </td> 
                    <td><a href="./faces/alterar.xhtml">Alterar</a> |
                        <a href="./faces/consultar.xhtml">Consultar</a></td> 
                </tr> 
            </tbody> 
        </table> 
    </p> 
</body> 

  • 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-17T21:56:56+00:00Added an answer on May 17, 2026 at 9:56 pm

    I am not sure of what you want to do at the end, but why don’t you use a <h:commandLink> (that will generate a <a> HTML tag) instead (don’t forget to nest your <h:datatable> in a <h:form>)?

    <h:form id="myForm">
        ...
        <h:dataTable id="grid1" value="#{postControle.lista}" var="post1">
            ...
            <h:column>
                <f:facet name="header"><h:outputText style="float: left; font-weight: bold;" value="Opções"/></f:facet>
                <h:commandLink action="#{postControle.alterar}" value="Alterar"/>
                <h:commandLink action="#{postControle.consultar}" value="Consultar"/>
            </h:column>
        </h:dataTable>
    

    Then, you define two actions in your Java bean (the String returned defines the navigation case to apply after the execution of the method):

    public String alterar() {
        ...
    }
    
    public String consultar() {
        ...
    }
    

    And in each action method, you can retrieve the corresponding element (i.e. post1) using the getRowData() method of the HtmlDatatable component:

    public String alterar() {
        HtmlDatatable table = (HtmlDatatable) FacesContext.getCurrentInstance().getViewRoot().findComponent("myForm:id1");
        YourClass element = (YourClass) table.getRowData();
        ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a customer index page that displays customer lists. I have a search
I have a page that is generated which inserts an HTML comment near the
I have a page that has an iframe From one of the pages within
I have a ListView on a page that displays a list of widgets. When
I have a page in my application that refreshes some content (a list of
I have a page that uses $(id).show(highlight, {}, 2000); to highlight an element when
I have a page that is hitting a webservice every 5 seconds to update
I have a page that is supposed to launch the Print Preview page onload.
I have a Page that has a single instance of a UserControl that itself
I have a page that contains a user control that is just a personalized

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.