0

I would like to add an JavaScript autocomplete functionality to a web form I am working on. I'm using NetBeans 7.1, Spring Framework 3.0.6 and Webflow 2.3. If possible, I would prefer to use JSP (rather than Tiles) if possible.

If you could suggest an approach or some written guide for me to follow. I already have a webflow for a five page form. I feed that an autocomplete would make a fairly complex form more user friendly if I could add this functionality. The AJAX needs to return an ID and name from the server in the first instance (presently page 1) and then validate whether a user entered already exists (possibly use an autocomplete again two pages later to avoid a duplicate database entry).

Any suggestions for an approach and/or guide would be appreciated.

RobH
  • 1
  • 5
  • Choose a JavaScript UI library proposing this kind of component (like jQuery-UI for example), read the documentation of the component to understand how it works, and add it to your JSP form. What's the problem exactly? – JB Nizet Jun 06 '12 at 07:16
  • Getting it to update with the webflow. Most of the examples use Tiles but I don't want to add this additional complexity to my app. – RobH Jun 06 '12 at 07:21
  • But Tiles has nothing to do with the usage of an autocomplete box. It's a templating engine. The way to integrate an autocomplete box into an app is exactly the same whether you use Tiles or not. – JB Nizet Jun 06 '12 at 08:21
  • So is there an example for using, say, JQuery with webflow without Tiles? I understand using a controller to do the job but what about webflow? Does webflow even come into it? – RobH Jun 06 '12 at 08:57

1 Answers1

0

So you're trying to autocomplete off of what was previously entered in the form?

Webflow allows for stateful beans, if your forms are all within the same flow, make sure your bean is set to flowScope and just return the information you need from that bean through an ajax call.

dardo
  • 4,870
  • 4
  • 35
  • 52
  • I intend to use the autocomplete to select a vendor and then later a contact in that business, adding new vendor or contact if required. I understand the MVC approach. But, what is the AJAX URL call? How is the Webflow state invoked? – RobH Jun 07 '12 at 01:59
  • You usually handle ajax calls through the use of fragments, here is the documentation http://static.springsource.org/spring-webflow/docs/2.0.x/reference/html/ch11s05.html – dardo Jun 07 '12 at 13:00
  • The Reference was one of the resources I used just before posting this question as it did not provide me with an answer. I framed my question the way I did because it did not provide me with the solution I wanted. I thought it should be possible to use JQuery without Tiles as @dardo above suggested. I didn't find the Reference very useful - only a short para covering a technology which I did not want to use. AJAX calls are simple with other languages and it seems to me they should be just as easy using Webflow. I just need to know how or have a how-to. – RobH Jun 09 '12 at 04:50
  • They aren't as easy due to the fact that ajax usually calls a stateless service (REST services), web flow contains a lot of stateful beans, making ajax more difficult. – dardo Jun 09 '12 at 05:38
  • Are you suggesting that it would be better to use some other techniques such as validation rather than the more difficult AJAX autocomplete? I'm open to suggestions to improve user experience. – RobH Jun 10 '12 at 01:54
  • You could look into a validator class for model validation. These validators are pretty easy to set up if you follow the documentation seen here: http://static.springsource.org/spring-webflow/docs/2.0.x/reference/html/ch04s10.html ... look under Implementing a Validator, it gets located under component scan, so it can be injected with services, but that'd make your validator pretty heavy, and I would not recommend it. – dardo Jun 11 '12 at 13:25
  • Thanks for the the suggestion, @dardo It looks like the reference will also give me a good place to start looking at this alternative solution. – RobH Jun 11 '12 at 15:45