You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jan Rosendahl <ja...@gmx.de> on 2009/05/14 14:31:33 UTC
YUI Plugin - parameters in Action are not set
Hi,
I try to use the yui:autocompleter (struts2yuiplugin-0.1-ALPHA-7.jar +
jsonplugin-0.33.jar )
Problem: The parameters in my Action class are not set ( by the params
interceptor ).
Maybe I have to put the params to the action-URL myself ?
short extract of my JSP is this:
..
<%@ taglib prefix="yui" uri="/struts-yui-tags" %>
<yui:head autocompleter="true" />
..
<s:form
id="productChoiceForm"
action="ProductList"
>
<div class="yui-skin-sam" >
<s:hidden id="categoryNo" name="categoryNo" />
<s:url id="productListUrl" namespace="/ajax"
action="ProductList" includeParams='none' />
<yui:autocompleter id="product" name="product"
href="%{#productListUrl}" containerCssStyle="width:100px" />
</div>
<s:submit type="input" cssClass="mySubmitButton"/>
</s:form>
...
( I changed the 'includeParams' parameter without any effect )
struts.xml has this action:
<package name="ajax" namespace="/ajax" extends="json-default">
<action name="ProductList" class="my.classpath.ajax.ProductList">
<result type="json">
<param name="root">options</param>
</result>
</action>
</package>
and the action has parameters+getter/setter for
product,productKey,categoryNo
but none of these parameters is initialized before the 'execute' method
is called (
with the 'getOptions' method it's the same thing ).
Any suggestion ( or may be a working example ) is appreciated ...
Jan
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: YUI Plugin - parameters in Action are not set
Posted by Jan Rosendahl <ja...@gmx.de>.
I've found some issues. Writing about this will solve the whole thing :-)
1)
the argument sent to the action is named 'query' (hard coded) while I
assumed it would be taken from the 'name'
( -> product in my case. (<yui:autocompleter ..name="product"..) )
That would be nice to be mentioned in the documentation
( at http://cwiki.apache.org/confluence/display/S2PLUGINS/YUI+Plugin )
So now I added set/getQuery to my action which took
me one step further.
But still the parameters are not set automatically. so I
2)
put the params into the autocompleter's href
But here is one problem : the URL is not built correctly
<s:url id="productListUrl"
namespace="/ajax"
action="ProductList"
includeParams='none'>
<s:param name="categoryNo" value="%{categoryNo}" />
<%--ProductList?category=9?query=1 (? instead of : between
category and query) --%>
</s:url>
Category is e.g. '9' and I get the URL:
'.../ProductList?category=9?query=1'
So I get 'category== '9?query=1' and query is not set anymore. So when the
URL is built it's assumed that there are no other parameters.
As for now in the getter for my category I will parse and split it myself
because I have to go on with my project - and wait for this to be fixed
or for someone who explains what's wrong here ..
comments are still welcome...
Jan
> ..
> <%@ taglib prefix="yui" uri="/struts-yui-tags" %>
> <yui:head autocompleter="true" />
> ..
> <s:form
> id="productChoiceForm"
> action="ProductList" > <div
> class="yui-skin-sam" > <s:hidden
> id="categoryNo" name="categoryNo" />
> <s:url id="productListUrl" namespace="/ajax"
> action="ProductList" includeParams='none'
> /> <yui:autocompleter
> id="product" name="product" href="%{#productListUrl}"
> containerCssStyle="width:100px" /> </div>
> <s:submit type="input" cssClass="mySubmitButton"/>
> </s:form> ...
>
> ( I changed the 'includeParams' parameter without any effect )
>
> struts.xml has this action:
>
> <package name="ajax" namespace="/ajax" extends="json-default">
> <action name="ProductList" class="my.classpath.ajax.ProductList">
> <result type="json">
> <param name="root">options</param>
> </result>
> </action> </package>
>
> and the action has parameters+getter/setter for
> product,productKey,categoryNo
> but none of these parameters is initialized before the 'execute'
> method is called (
> with the 'getOptions' method it's the same thing ).
>
> Any suggestion ( or may be a working example ) is appreciated ...
>
> Jan
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: YUI Plugin - parameters in Action are not set
Posted by Jan Rosendahl <ja...@gmx.de>.
sorry for the mess, Thunderbird scrambled my text a little bit ...
Jan
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org