0

How in zscript send request to anotherpage?

asked 2007-04-04 07:39:55 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4242735

By: westpine

Hi! I need to write zscript function that will be used somewhere in "onClick"
action that will send request to servlet or jsp-page and pass some parameters there with POST. How it could be done?

delete flag offensive retag edit

11 Replies

Sort by ยป oldest newest

answered 2007-04-04 08:28:33 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4242802

By: jumperchen

Executions.getCurrent().sendRedirect("newWindow.zul"); or Executions.getCurrent().forward("newWindow.zul");

Jumper

link publish delete flag offensive edit

answered 2007-04-04 08:28:36 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4242801

By: alanmehio

Hi,
try this

Executions.getCurrent().getNativeRequest();
or
Object obj = desktop.getExecution.getCurrent().getNativeRequest();
// make a check
if(obj != null) {

javax.servlet.ServletRequest request = (javax.servlet.ServletRequest)obj;

// same for response
Object obj = desktop.getExecution.getCurrent().getNativeResponse();
// etc..


// code here for passing some param

request.setAttribute("key1", "val");


} // if

I hope this could help
Regards,
Alan Mehio
London, UK



link publish delete flag offensive edit

answered 2007-04-04 08:33:47 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4242811

By: alanmehio


request.getRequestDispatcher("url").forward(request, response);


Cheers
Alan Mehio
London, UK

link publish delete flag offensive edit

answered 2007-04-04 08:43:48 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4242827

By: westpine

Thanks a lot! One more... If I call sendRedirect("some.zul") will previously added to request parameters will be passed there?

link publish delete flag offensive edit

answered 2007-04-04 09:23:28 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4242882

By: westpine

I have following code:
<zscript>
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponce;

ServletRequest request = null;
ServletResponse response = null;

Object obj1 = desktop.getExecution.getCurrent().getNativeRequest();
if(obj1 != null) request = (javax.servlet.ServletRequest)obj1;

Object obj2 = desktop.getExecution.getCurrent().getNativeResponse();
if(obj2 != null) response = (javax.servlet.ServletResponse)obj2;

request.setAttribute("key1", "val1");
request.getRequestDispatcher("/1.jsp").forward(request, response); </zscript>

And got error. What is wrong?



link publish delete flag offensive edit

answered 2007-04-06 02:34:08 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4245816

By: jumperchen

Hi,

Some typo, try to use the following code.

<zscript>
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

ServletRequest request = null;
ServletResponse response = null;
Object obj1 = Executions.getCurrent().getNativeRequest();
if(obj1 != null) request = (javax.servlet.ServletRequest)obj1;

Object obj2 =Executions.getCurrent().getNativeResponse();
if(obj2 != null) response = (javax.servlet.ServletResponse)obj2;

request.setAttribute("key1", "val1");
request.getRequestDispatcher("/1.jsp").forward(request, response); </zscript>

Jumper

link publish delete flag offensive edit

answered 2007-04-06 07:39:18 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4246023

By: westpine

Thanks Jumper. But when I used yor code i recieved error "Cannot forward after response has been committed". What is wrong now? :-)

link publish delete flag offensive edit

answered 2007-04-06 07:40:03 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4246026

By: westpine

May be I should use send Executions.getCurrent().sendRedirect(), but how to pass parameters within it?

link publish delete flag offensive edit

answered 2007-04-06 15:45:05 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4246582

By: jumperchen

Hi,

I don't make any change but it works for me. :)

This is a way to simplify as follows,

<zscript>
Executions.getCurrent().setAttribute("key1", "val1"); Executions.getCurrent().forward("/1.jsp");
</zscript>

About your question,

I think you can use the
Executions.getCurrent().sendRedirect("/newWindow.zul?a=a&b=b"); , if you want to pass some parameters of the request for using sendRedirect method .


Best Regards,
Jumepr


link publish delete flag offensive edit

answered 2007-04-10 07:11:50 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4252468

By: westpine

Thanks Jumper!!! You saved my a... well thanks a lot! :-)

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: 2007-04-04 07:39:55 +0800

Seen: 1,096 times

Last updated: Feb 16 '09

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