Here are some points :
- I have a primefaces autocomplete example that makes use of a POJO with a custom converter.
- Im returning a UUID string for the getAsString in the converter.
- 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.
- 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.
- 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