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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:59:46+00:00 2026-05-28T03:59:46+00:00

XHTML side: <p:dataTable id=selectProductTable var=product value=#{manageFormsView.productModel} selection=#{manageFormsView.product} > bean side: private SelectableDataModel<Product> productModel=new SelectableDataModel<Product>()

  • 0

XHTML side:

<p:dataTable id="selectProductTable" var="product"  value="#{manageFormsView.productModel}" selection="#{manageFormsView.product}" >

bean side:

  private SelectableDataModel<Product>  productModel=new SelectableDataModel<Product>() {


                @Override  
                public Product getRowData(String rowKey) {  
                    //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data  


                    for(Product product : productList) {  
                        if(product.getModel().equals(rowKey))  
                            return product;  
                    }  

                    return null;  
                }  

                @Override  
                public Object getRowKey(Product p) {  
                    return p.getModel();  
                }  
        };

i do not want to generate a new class which implements SDM, can not i do inline implementaton like above?

I am getting exception:

javax.faces.FacesException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled.
  • 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-28T03:59:46+00:00Added an answer on May 28, 2026 at 3:59 am

    The exception message is misleading. Implementing only the SelectableDataModel interface is not sufficient. You also need to extend an DataModel implementation such as ListDataModel. That can’t be done in flavor of an anonymous class. You really need to create another class.

    public class ProductDataModel extends ListDataModel<Product> implements SelectableDataModel<Product> {
    
        // ...
    
    }
    

    You can if necessary generify it if you have a common base entitiy (with getId() and so on), so that you don’t need to create another one for every entity.

    public class BaseEntityDataModel<E extends BaseEntity> extends ListDataModel<E> implements SelectableDataModel<E> {
    
        // ...
    
    }
    

    As a completely different alternative, you can also use rowKey attribtue of the <p:dataTable> and let it refer exactly the same value as SelectableDataModel#getRowKey(). This way you don’t need the whole SelectableDataModel interface anymore.

    <p:dataTable ... rowKey="#{product.model}">
    

    See also:

    • PrimeFaces showcase example
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When running on an xhtml page, xpath doesn't seem to return any results. var
I need to get the client-side instance of a RadComboBox (or the newly-selected value
All the time, I use PHP on server side to generate HTML/XHTML directly or
Let's say I have the following table in my XHTML page: <tr:table id=listRowsTable var=bb
In XHTML Strict, it seems that you're not allowed to use the <u> tag
HTML (or maybe just XHTML?) is relatively strict when it comes to non-standard attributes
I have an XHTML strict page that has an invisible div that is controlled
My website is XHTML Transitional compliant except for one thing : the & (ampersand)
I've got an XHTML 1.0 Transitional document. Most of the content is in English,
so i heard that XHTML is not supported by IE and so it is

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.