You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by clanmilano <cl...@gmail.com> on 2011/07/30 23:39:50 UTC

How to send selected item in sj:autocompleter through url as a param

Hello! I'm working on a struts2 (2.2.3) web app, using jquery plugin (3.0.0)
for ajax.

Right  now I'm facing this problem:

I have a jsp in which I have 2 sj:autocompleter (the first one for providers
and the second one for products). I need to filter the products by the
provider selected. In this particular application is a must to have an
autocompleter for the second collection.

After looking at struts2 and jquery documentation, I found that the
autocompleter used to have a bug for the listenTopics that it is not
triggering it: http://code.google.com/p/struts2-jquery/issues/detail?id=243
And as I could face here, the listenTopics is still not working since the
topic published by the first autocompleter is not trigger unless I change
the second autocompleter to be a sj:select or any other ajax component. I
tried updating the versions of the jars used, but the problem is still
there.

So, in order to fix this particular case the only way I found is to send in
the url the value selected in the first  sj:autocompleter as a parameter so
that I'm able to use that selection for filtering the second
sj:autocompleter.

Part of my code:

jsp:

<s:url id="url_products" action="myAction" method="showProducts">
	<s:param name="providerSelected" value="%{purchase.provider.id}"></s:param>
</s:url>

<sj:autocompleter 
id="purchaseProviderId" 
name="purchaseProvider" 
value="%{purchaseProvider}"
onCompleteTopics="providerChanged" <!--this topic is not listened by the
second autocompleter -->
cssClass="product"
href="%{url_providers}"
/>

<sj:autocompleter 
id="productId" 
name="productDescription" 
value="%{productDescription}"
listenTopics="providerChanged" <!-- not working -->
href="%{url_products}"
/>

The problem I'm having now is that "%{purchase.provider.id}" is something
selected exactly before sending the url_products and that when I send the
value through the url the value is not updated from the latest selection
done. 
What I think is that this value is part of the session and since the new
selection done for the provider has not been submitted yet to the action,
"%{purchase.provider.id}" is just pointing to the value the session is aware
of.

Questions:
1) Do you know if there is going to be a fix for the autocompleter to have
the listenTopics completely working?
2) How can I send the value recently selected in "purchaseProviderId"
through the url as a param?

Thanks in advance!

--
View this message in context: http://struts.1045723.n5.nabble.com/How-to-send-selected-item-in-sj-autocompleter-through-url-as-a-param-tp4650734p4650734.html
Sent from the Struts - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org