0
votes

Here are some points :

  1. I have a primefaces autocomplete example that makes use of a POJO with a custom converter.
  2. Im returning a UUID string for the getAsString in the converter.
  3. The string value from the converter is sent fine if i choose the value from the autocomplete dropdown dialog, either by keyboard or mouse click.
  4. But when i type the value myself without choosing from the autocomplete dropdown dialog, or just pasted the value into the text field, the Validation Error: Value is required. error will happen.
  5. I notice this error happens because the value sent to the server side is not the string generated by my converter, but the value typed itself.

Using firebug shows this in action.

This is when the i choose the value from autocomplete dropdown dialog, either by keyboard or mouseclick, we can notice the value is in the UUID format, which is returned by my pojo converter :

<input aria-haspopup="true" aria-autocomplete="list" role="textbox" 
  autocomplete="off" id="DetailDialogForm:Bagian_input" 
  name="DetailDialogForm:Bagian_input" value="PERSO" 
  class="ui-inputfield ui-widget ui-state-default ui-corner-all ui-autocomplete-input" 
  type="text">
<input id="DetailDialogForm:Bagian_hinput" 
  name="DetailDialogForm:Bagian_hinput" 
  value="b0019ab2-28c3-451a-90f6-62a6941ffcaa" type="hidden">

This is when the i typed or pasted the value, we can notice the value is exactly what i typed, which is NOT returned by my pojo converter :

<input aria-haspopup="true" aria-autocomplete="list" 
  role="textbox" autocomplete="off" id="DetailDialogForm:Bagian_input" 
  name="DetailDialogForm:Bagian_input" value="PERSO" 
  class="ui-inputfield ui-widget ui-state-default ui-corner-all ui-autocomplete-input" 
  type="text">
<input id="DetailDialogForm:Bagian_hinput" 
  name="DetailDialogForm:Bagian_hinput" value="PERSO" type="hidden">

Is this the intended behaviour of this element ?


Im using tomcat 7, and these are my dependencies :

<dependency>
    <groupId>org.primefaces</groupId>
    <artifactId>primefaces</artifactId>
    <version>2.2.1</version>
</dependency>
<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.0.4-b09</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>2.0.4-b09</version>
    <scope>compile</scope>
</dependency>

Please share your thoughts, thank you !


UPDATE


This is the JSF excerpt :

<p:autoComplete id="Bagian" label="Bagian yang di limpahkan"
    value="#{tInputBean.activeDetail.map['department']}"
    completeMethod="#{tInputBean.filterDepartment}" var="department"
    itemLabel="#{department.map['departmentName']}"
    itemValue="#{department}" converter="genericConverter"
    forceSelection="true" required="true" />

And the converter is available at this page, in BalusC's answer on EntityConverter


1

1 Answers

0
votes

Would you post your .xhtml, i need to check the <p:autoComplete />

Please check:

  1. do you have added <p:autoComplete> attribute forceSelection
  2. When user select on list of suggestions given by autoComplete, it should use use selectListener, and update partial view using onSelectUpdate

  3. check if there is <p:ajax/> inside <p:autoComplete/>, try to remove it