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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:46:23+00:00 2026-06-13T20:46:23+00:00

I’ve got a simple composite component which has to render a inputText. When a

  • 0

I’ve got a simple composite component which has to render a inputText. When a put the value and press commandButton the follow exception is throw:

java.lang.IllegalArgumentException: Cannot convert 1 of type class java.lang.String to class sample.entity.Product

When i use h:inputText instead d:myInputText it’s work fine.

Is possible use a FacesConverter and attribute forClass for composite component? I do not like to use converter attribute or converterId of tag f:converter.
Anybody help me?

Page code:

<h:form>
  <h:messages />
  Product Id: <h:myInputText value="#{productController.product}"/>
  <h:commandButton value="Submit" action="#{productController.someAction()}" />
  Product Description: <h:outputText value="#{productController.product.description}"/>
</h:form>

Composite code:

<composite:interface>
   <composite:attribute name="value"/>
   <composite:editableValueHolder name="value" targets="#{cc.clientId}:value"/>
</composite:interface>

<composite:implementation>
   <div id="#{cc.clientId}">
      <h:inputText id="value" value="#{cc.attrs.value}"/>
      <h:message for="#{cc.clientId}:value" />
    </div>
</composite:implementation>

ManagedBean code:

@Named("productController")
@RequestScoped
public class ProductController {

  private Product product;

  public Product getProduct() {
    if (product == null) {
        product = new Product();
    }
    return product;
  }

  public void setProduct(Product product) {
    this.product = product;
  }

  public void someAction() {
    System.out.println("Product " + product);
  }
}

Converter code:

@FacesConverter(forClass = Product.class)
public class ProductConverter implements Converter {

  @Override
  public Object getAsObject(FacesContext fc, UIComponent uic, String value) {
    System.out.println("[DEBUG] getAsObject: " + value);
    if (value == null || "".equals(value)) {
        return null;
    }
    //TODO: some logic to get entity from database.
    return new Product(new Long(value));
  }

  @Override
  public String getAsString(FacesContext fc, UIComponent uic, Object o) {
    System.out.println("[DEBUG] getAsString: " + o);
    if (o == null) {
        return null;
    }
    return String.valueOf(((Product) o).getId());
  }
}

Entity code:

 public class Product {

      private Long id;
      private String description;

      public Product() {
      }

  public Product(Long id) {
    this.id = id;
  }

  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  @Override
  public int hashCode() {
    int hash = 7;
    hash = 29 * hash + (this.id != null ? this.id.hashCode() : 0);
    return hash;
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    final Product other = (Product) obj;
    if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
        return false;
    }
    return true;
  }

  @Override
  public String toString() {
    return "Product{" + "id=" + id + '}';
  }
}

I use Mojarra 2.1.14, Glassfish 3.1 and CDI.
Best regards.

  • 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-13T20:46:25+00:00Added an answer on June 13, 2026 at 8:46 pm

    I was able to reproduce it in Mojarra 2.1.14. This is a bug in Mojarra. It works fine in MyFaces 2.1.9. I’ve reported it to Mojarra guys as issue 2568. In the meanwhile, there’s not really another option than explicitly specifying a <f:converter for> in the client or moving to MyFaces (which has its own set of specific quirks/issues as well though).

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

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.