0

How to do a post?

asked 2008-11-20 15:10:04 +0800

2ichigo2 gravatar image 2ichigo2
9

Hi I have been reading the docs and trying out codes.
Still i am not able to achieve a do post to another url.

Example at the "/zk/search.zul" page,
After selecting a user from this search page, i want to do a post to "/zk/edit.zul" page with the selected userId.
Then i can retrieve the userId from the request as a parameter and load the details for edit.

Currently, i am using Executions.getCurrent().sendRedirect("/zk/edit.zul?userId=1") to do the page forwarding.
But going through this method is a doGet rather than a doPost.

Cany anyone please advise me?

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2008-11-20 16:13:43 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

http://www.zkoss.org/smalltalks/legacy-validate/legacy-validate.html

link publish delete flag offensive edit

answered 2008-11-21 01:50:58 +0800

2ichigo2 gravatar image 2ichigo2
9

Thanks Dennis, but i am not trying to do validation.

Example source on what i am trying to do:

<zscript>
public void forwardToEditScreen(Listbox listbox){
Listitem item = listbox.getSelectedItem();
String userId = item.getAttribute("userId");
//TO do a post to editWindow but currently only know how to do a redirect with doGet
Executions.getCurrent().sendRedirect("/edit_user.zul?userId="+userId);
}
</zscript>

<listbox id="users" onSelect="forwardToEditScreen(self)">
<listitem value="user1"/>
...
...
</listbox>

So how do i do a POST rather than a GET??

link publish delete flag offensive edit

answered 2008-11-21 09:22:19 +0800

ziccardi gravatar image ziccardi
321 7

I think it would be much easier to work another way.


Try this:

<window id="mainWin">
<zscript>
 public void forwardToEditScreen(Listbox listbox)
 {
    while(content.getFirstChild() != null)
        content.removeChild(content.getFirstChild());

       Map mParams = new HashMap();

       mParams.put("USER", listbox.getSelectedItem().getValue());
       Executions.createComponents("/edit_user.zul", content, mParams);
       // Now, your component, can access the User with Executions.getCurrent().getArg().get("USER");
 }
</zscript>
   <window id="content">
     <listbox id="users" mold="select" onSelect="forwardToEditScreen(self)" >
     <listitem value="user1">
         <listcell label="pippo"/>
     </listitem>
     <listitem value="user2">
         <listcell label="pluto"/>
     </listitem>
     </listbox>
   </window>
</window>

link publish delete flag offensive edit

answered 2008-11-21 09:24:37 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

updated 2008-11-21 09:26:19 +0800

did you read the document ?

check these parts in document

1. a form for submit
<h:form id="updateForm" action="/updateProfile" xmlns:h="http://www.w3.org/1999/xhtml">

2. name the component need to be submit with a 'name' attribute
<textbox id="firstName" name="firstName" .....

3.submit form by ..
Clients.submitForm(Component form);
Clients.submitForm(String formId);

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-11-20 15:10:04 +0800

Seen: 283 times

Last updated: Nov 21 '08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More