You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Tony Zhang <zh...@hotmail.com> on 2008/01/23 01:55:28 UTC
[S2]question about S2+YUI+JSON.
I want to write a demo using S2+YUI+JSON. And I got an issue about async call
struts2 action.
In my jsp file, there is call struts action. I want to submit same data to
sever and the server return the json result. But I fount the json plugin
can't populate the parameter form request to action.
Javascript sumbit some data,
var sUrl = "dragDropPost.action";
YAHOO.util.Connect.asyncRequest('POST', sUrl, callback,
"list1="+parseList(ul1, "List 1")+"&list2="+parseList(ul2, "List 2"));
Struts.xml
<action name="dragDropReturn" class="test.DragDropAction"
method="execute">
<interceptor-ref name="json"/>
<result />
</action>
Action,
public class DragDropAction extends ActionSupport {
private String list1;
private String list2;
private Map map = new HashMap();
public String execute()
{
map.put("Content", "Hello Paciolan");
return Action.SUCCESS;
}
public String getList1() {
return list1;
}
public void setList1(String list1) {
this.list1 = list1;
}
public String getList2() {
return list2;
}
public void setList2(String list2) {
this.list2 = list2;
}
public Map getMap()
{
return map;
}
public void setMap(Map value)
{
map = value;
}
}
I found the list1 and list2 were not populated when I submit the data.
What should I do?
--
View this message in context: http://www.nabble.com/-S2-question-about-S2%2BYUI%2BJSON.-tp15032587p15032587.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
Re: [S2]question about S2+YUI+JSON.
Posted by Tony Zhang <zh...@hotmail.com>.
Thanks,
I have a question about how to encode the data when sumbit data by YUI.
Like below,
var postData = "username=anonymous&userid=0";
function makeRequest(){
var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback,
postData);
}
How can I encode the postData?
--
View this message in context: http://www.nabble.com/-S2-question-about-S2%2BYUI%2BJSON.-tp15032587p15033916.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
Re: [S2]question about S2+YUI+JSON.
Posted by Frans Thamura <fr...@meruvian.org>.
On Jan 23, 2008 8:20 AM, Musachy Barroso <mu...@gmail.com> wrote:
> You don't need to use the json interceptor to populate the params in
> the action. Struts will do that for you.
>
> musachy
musachy,
when will ur json 1.0 stable?
F
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2]question about S2+YUI+JSON.
Posted by Musachy Barroso <mu...@gmail.com>.
You don't need to use the json interceptor to populate the params in
the action. Struts will do that for you.
musachy
On Jan 22, 2008 7:55 PM, Tony Zhang <zh...@hotmail.com> wrote:
>
> I want to write a demo using S2+YUI+JSON. And I got an issue about async call
> struts2 action.
>
> In my jsp file, there is call struts action. I want to submit same data to
> sever and the server return the json result. But I fount the json plugin
> can't populate the parameter form request to action.
>
> Javascript sumbit some data,
>
> var sUrl = "dragDropPost.action";
> YAHOO.util.Connect.asyncRequest('POST', sUrl, callback,
> "list1="+parseList(ul1, "List 1")+"&list2="+parseList(ul2, "List 2"));
>
>
> Struts.xml
>
> <action name="dragDropReturn" class="test.DragDropAction"
> method="execute">
> <interceptor-ref name="json"/>
> <result />
> </action>
>
>
> Action,
>
> public class DragDropAction extends ActionSupport {
>
> private String list1;
> private String list2;
> private Map map = new HashMap();
>
> public String execute()
> {
> map.put("Content", "Hello Paciolan");
> return Action.SUCCESS;
> }
>
> public String getList1() {
> return list1;
> }
>
> public void setList1(String list1) {
> this.list1 = list1;
> }
>
> public String getList2() {
> return list2;
> }
>
> public void setList2(String list2) {
> this.list2 = list2;
> }
> public Map getMap()
> {
> return map;
> }
>
> public void setMap(Map value)
> {
> map = value;
> }
> }
>
> I found the list1 and list2 were not populated when I submit the data.
>
> What should I do?
> --
> View this message in context: http://www.nabble.com/-S2-question-about-S2%2BYUI%2BJSON.-tp15032587p15032587.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
>
>
--
"Hey you! Would you help me to carry the stone?" Pink Floyd
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org