You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by toytown <pr...@gmail.com> on 2012/03/08 09:01:01 UTC

Making Autocomplete Form Stateless

 I am really facing some hard time making Autocomplete Form statless. The
problem basically stems from 
AutoCompleteBehavior which extends AbstractAutoCompleteBehavior which
evetually extends AbstractAjaxBehavior.

AbstractAjaxBehavior implements IBehaviorListener. I saw in the the
Component class that the method
	public boolean getStatelessHint(Component component)
	{
		if (this instanceof IBehaviorListener)
		{
			// this behavior implements a callback interface, so it cannot be
stateless
			return false;
		}
		return true;
	}

So any behaviour implementing IBehaviourlistner is stateful in nature (which
I think is little too restrictive) and closes down possibility to make
AutoComplete behaviour stateless.

Perhaps I am insane  but I do not see any point why Autocomplete behaviour
should be "Stateful" all the time and in every context of Web Page.  I fully
understand the advantages of being "Stateful" in most of complex web
interaction but to have a way to make some components Stateless in nature
would be nice.

 
I am not Wicket expert but I would rather do something like 

extends IBehaviorListener and include a method

 getStatelessHint(Component c) ;

 
then in org.apache.wicket.Component class implement the method
getStatelessHint in a slightly different way

	public boolean getStatelessHint(Component component)
	{
		if (this instanceof IBehaviorListener)
		{
			return this.getStatelessHint(component);
		}
		return true;
	}



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Making-Autocomplete-Form-Stateless-tp4455817p4455817.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Making Autocomplete Form Stateless

Posted by "Serban.Balamaci" <th...@gmail.com>.
I think Martin was pretty explicit with the fact that you could use as
endpoint an AbstractResource or even a plain servlet as your data source
url, you don't need explicitly an ajax behaviour(although just setting the
stateless hint to true on the ajaxbehaviour might work without any
problems).

You can add
http://thewicketevangelist.blogspot.de/2011/12/marrying-wicket-and-jquery-ui.html
but any implementation would work, and use the url of your
mountResource(IResource) on where you return a JSON based on the query
parameters.
 
You don't even need to add the ajax behaviour to contribute the autocomplete
JS(which is a static string if the data url is not dynamic) to your panel so
your page is stateless. 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Making-Autocomplete-Form-Stateless-tp4455817p4649853.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Making Autocomplete Form Stateless

Posted by romanasu <da...@yahoo.com>.
So, did somebody manage to do have an auto complete behavior into an
stateless wicket page? 
Maybe an integration of jquery ? Any examples, ideas?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Making-Autocomplete-Form-Stateless-tp4455817p4649849.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Making Autocomplete Form Stateless

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

I see you are not expert in Java either ;-)
Your code suggestion will lead to StackOverflowError because it goes
in infinite recursion.

Wicket's Ajax behaviors are stateful. To be able to find the component
that will feed the autocompleter the page should be preserved.
There are some stateless Ajax behaviors provided by Jolira
(https://github.com/jolira/wicket-stateless) but we have several times
discussed here in the mailing list that they don't work in all use
cases so they cannot be part of Wicket framework itself.

Additionally #getStatelessHint() method is not final. You can always
override it and tweak it until it works as you wish. But in this case
obviously we will not support any problems caused by these tweaks.

I recommend you to use an autocompleter provided by your favorite JS
library that will get its data from either Wicket IResource or just a
plain Servlet.

On Thu, Mar 8, 2012 at 10:01 AM, toytown <pr...@gmail.com> wrote:
>  I am really facing some hard time making Autocomplete Form statless. The
> problem basically stems from
> AutoCompleteBehavior which extends AbstractAutoCompleteBehavior which
> evetually extends AbstractAjaxBehavior.
>
> AbstractAjaxBehavior implements IBehaviorListener. I saw in the the
> Component class that the method
>        public boolean getStatelessHint(Component component)
>        {
>                if (this instanceof IBehaviorListener)
>                {
>                        // this behavior implements a callback interface, so it cannot be
> stateless
>                        return false;
>                }
>                return true;
>        }
>
> So any behaviour implementing IBehaviourlistner is stateful in nature (which
> I think is little too restrictive) and closes down possibility to make
> AutoComplete behaviour stateless.
>
> Perhaps I am insane  but I do not see any point why Autocomplete behaviour
> should be "Stateful" all the time and in every context of Web Page.  I fully
> understand the advantages of being "Stateful" in most of complex web
> interaction but to have a way to make some components Stateless in nature
> would be nice.
>
>
> I am not Wicket expert but I would rather do something like
>
> extends IBehaviorListener and include a method
>
>  getStatelessHint(Component c) ;
>
>
> then in org.apache.wicket.Component class implement the method
> getStatelessHint in a slightly different way
>
>        public boolean getStatelessHint(Component component)
>        {
>                if (this instanceof IBehaviorListener)
>                {
>                        return this.getStatelessHint(component);
>                }
>                return true;
>        }
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Making-Autocomplete-Form-Stateless-tp4455817p4455817.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org