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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:09:10+00:00 2026-06-03T22:09:10+00:00

I am looking to pass multiple parameters from the following Primefaces 3.1 p:datatable: <p:dataTable

  • 0

I am looking to pass multiple parameters from the following Primefaces 3.1 p:datatable:

 <p:dataTable value="#{tableBean.carsModel}" var="var" rowkey="#{var.model}" 
              selection="#{tableBean.car}" selectionMode="single">
    <p:ajax event="rowSelect" listener="#{tableBean.onRowClick}"></p:ajax>
    <p:column>
        <f:facet name="header">
            <h:outputText styleClass="outputText" value="Model"></h:outputText>
        </f:facet>
        <h:outputText styleClass="outputText" value="#{var.model}"></h:outputText>
    </p:column>
    <p:column>
        <f:facet name="header">
            <h:outputText styleClass="outputText" value="Color"></h:outputText>
        </f:facet>
        <h:outputText styleClass="outputText" value="#{var.randomColor}"></h:outputText>
    </p:column>
</p:dataTable>

I have a situation where I have more than 1 key as primary key, I am using rowkey="#{var.model} but, how to work with multiple primary keys.

I am also using CarDataModel extends ListDataModel<Car> implements SelectableDataModel<Car>{ class. Can somebody tell me how to work with?

@Override
public Car getRowData(String rowKey) {
    //In a real app, a more efficient way like a query by rowKey 
    //should be implemented to deal with huge data
    List<Car> cars = (List<Car>) getWrappedData();
    for(Car car : cars) {
        if(car.getModel().equals(rowKey))
            return car;
    }
    return null;
}

@Override
public Object getRowKey(Car car) {
    return car.getModel();
}

Any help is appreciated.

  • 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-03T22:09:13+00:00Added an answer on June 3, 2026 at 10:09 pm

    You’d need to use the composite key instead as row key.

    E.g.

    rowKey="#{car.compositeKey}"
    

    Or if you insist in using SelectableDataModel:

    @Override
    public Car getRowData(String rowKey) {
        List<Car> cars = (List<Car>) getWrappedData();
    
        for (Car car : cars) {
            if (car.getCompositeKey().equals(rowKey))
                return car;
        }
    
        return null;
    }
    
    @Override
    public Object getRowKey(Car car) {
        return car.getCompositeKey();
    }
    

    As to the concrete implementation of getCompositeKey(), it’s unclear what two primary keys you have and what persistence API you’re using. JPA for example has already support for composite keys and so your entity should already support it. But if you’re not using JPA for some reason, then here’s an example which assumes that both the model and the color represent the composite key, just to illustrate the idea:

    public String getCompositeKey() {
        return model + "." + color;
    }
    

    Or

    public Object[] getCompositeKey() {
        return new Object[] { model, color };
    }
    

    Or whatever uniquely represents as composite key based on Object#equals() contract.

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

Sidebar

Related Questions

I have been looking long for a solution how to pass the value from
I would like to pass multiple parameters from the iphone sdk to a server-side
Looking to pass variables from c# to javascript to use some jquery code. Passing
I'm looking to pass parameters into a Windows Service not only upon launch but
I'm looking to pass the value selected in the drop box when I click
I'm fairly new to objective-c, and am looking to pass a number of key-value
Something I've noticed from looking at multiple .NET starter kits is that business object
I'm looking for a good solution to pass two generic objects to a viewpage
I am looking for a way to pass a string containg the * character
I'm looking for a way to pass a variable or string or anything into

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.