-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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?
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
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
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
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?
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?
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
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? :-)
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?
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
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4252468
By: westpine
Thanks Jumper!!! You saved my a... well thanks a lot! :-)
Asked: 2007-04-04 07:39:55 +0800
Seen: 1,096 times
Last updated: Feb 16 '09