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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:37:01+00:00 2026-05-25T23:37:01+00:00

Let’s say we have a simple table defined as: <p:dataTable value=#{testBean.dummyStringData} var=data> <p:column> <p:commandLink

  • 0

Let’s say we have a simple table defined as:

<p:dataTable value="#{testBean.dummyStringData}" var="data">
    <p:column>
        <p:commandLink action="#{testBean.printData(data)}">
            <h:outputLabel value="#{data}" />
        </p:commandLink>
    </p:column>
</p:dataTable>

And a simple backing bean:

 public class TestBean {

    private List<String> dummyStringData = new ArrayList<String>();

    //getters and setters omitted 

    @PostConstruct
    public void postConstruct() {
        dummyStringData.add(new String("DummyData1"));
        dummyStringData.add(new String("DummyData2"));
        dummyStringData.add(new String("DummyData3"));
    }

    public void printData (String data) {
        System.out.println(data);
    }

Predictably, clicking on a link within the table will print the content of the clicked row to stdout.

Now, I would like for the printData method to be also called when a user hovers the mouse cursor over the p:commandLink within the table. To accomplish that I’ve tried nesting a p:ajax element inside the p:commandLink element:

<p:commandLink action="#{testBean.printData(data)}">
    <p:ajax event="mouseover" listener="#{testBean.printData(data)}" />
    <h:outputLabel value="#{data}" />
</p:commandLink>

This approach doesn’t seem to work for p:commandLink and p:commandButton component. Hovering the mouse over the link seems to do nothing. If I were to use a component other than those two (i.e. a p:inputText and nest a p:ajax like the above) I get the expected behaviour.

Now, using a p:commandLink‘s onmouseover and p:remoteCommand I do manage to trigger the appropriate ajax event:

<p:commandLink action="#{testBean.printData(data)}" onmouseover="rc()">
    <h:outputLabel value="#{data}" />
</p:commandLink>
<p:remoteCommand name="rc" action="#{testBean.printData(data)}" />

However, the data variable passed as a parameter to the printData method isn’t specific to the row from which the event was triggered. Instead, the last element from the collection is always used (in this case, that would be “DummyData3”).

I’m using Primefaces 3.0.M3 on MyFaces 2.1.3 with Tomcat 7.

Cheers!

  • 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-25T23:37:02+00:00Added an answer on May 25, 2026 at 11:37 pm

    There’s a solution on the PrimeFaces forum.

    Alternatively…

    I suspect that because the name of the generated JavaScript function will be the same for each iteration, the last one is the winner. You could do something like this to give each one a unique name:

    <p:dataTable value="#{testBean.dummyStringData}" var="data" rowIndexVar="rowIndex">
        <p:column>
            <p:commandLink action="#{testBean.printData(data)}" onmouseover="rc_#{rowIndex}()">
                <h:outputLabel value="#{data}" />
            </p:commandLink>
            <p:remoteCommand name="rc_#{rowIndex}" action="#{testBean.printData(data)}" />
        </p:column>
    </p:dataTable>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say we have a simple function defined in a pseudo language. List<Numbers> SortNumbers(List<Numbers>
Let's say I'm building a data access layer for an application. Typically I have
let's say i have list looking like this: <select name=name id=id> <option value=10176232332>David</option> <option
Let's say I have a link in a table like: <td class=ms-vb width=100%> <a
Let's say I have a table that looks something like this: ------------------------------- id|column2|column3 |column4
Let's say I have a property foo defined in my parent POM. Is it
Let’s say I have a data grid and there’s a method attached to clicking
Let's say I have the following, declare @A table (a int) insert into @A
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say I have a drive such as C:\ , and I want to

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.