-1

I have dialogbox which consists an autocomplete element and several other fields depending on it. What I want is to run completeMethod when autocomplete field is empty. However, this method executes only there is one or more character in the field. For instance, assume I typed 'x', then if I remove it, it should be called. I need to know if it is empty because I will change other fields according to it. I already tried minLength but it has no effect whatsoever

<p:autoComplete id="findCommand" value="ControllerClass.someObject 
completeMethod="#{ControllerClass.completeCommand-returns objects-}/..>
<p:ajaxlistener="#{ControllerClass.onCommandChange} update="someotherfield"
event="itemSelect" /></p:autoComplete>

The completeCommand method won't be called if the field is empty. Here is what I tried:
1- I added an ajax tag with change and assigned some other method to it to control the field. But it ruins itemSelect ajax, since it tries to assign query string to object when user types something, which is wrong.
2- I tried to use second answer, however since I can't figure out if field is empty, it has no use: JSF access html element value in bean class

Cœur
  • 37,241
  • 25
  • 195
  • 267
sarah
  • 580
  • 1
  • 6
  • 24
  • 1
    PLEASE, PLEASE, PLEASE read the documentation. Where does it state that 'minLength' should work? And the solution is in there. – Kukeltje Sep 01 '16 at 09:20
  • You are right, I totally forgot to check it and solution is really simple. I am sorry, will be careful about this next time. – sarah Sep 01 '16 at 10:33

1 Answers1

1

minQueryLength = "0" worked. Here is the link I've found this.

http://www.primefaces.org/docs/vdl/6.0/core/

You can select autocomplete from the left menu

sarah
  • 580
  • 1
  • 6
  • 24
  • Wrong link!!! it is about 3.5 vdl documentation that is old. Always refer to the current tag documentation http://www.primefaces.org/docs/vdl/6.0/core/ or better yet, to the PDF documentation. And a good IDE will help to... ctrl+space will do completion and show you the options! – Kukeltje Sep 01 '16 at 10:36