A question about HTTP requests in ZK
I haven't use VRaptor before.
But in your code,
evt.getPage().setVariable("client", c); ==> save a variable to current page
Executions.sendRedirect("/client/view/"); ==> redirect to a new page
Therefore, it is null.
I was wrong when I though Vraptor could get the data. The thing is, vraptor is page-centric, and zk is event-centric. Vraptor can get the data if it comes attached to a form, in the submit button style. I don't know how zk manages the data in a ajax request, but it's not compatible with vraptor.
Peter, is there any way to send this data do another page, like a forward instead of a redirect?
Please refer to the api, and see how forward is used.
http://www.zkoss.org/javadoc/5.0/zk/org/zkoss/web/servlet/http/HttpServlet.html
Hello, I could not read the article. I wonder how ZK works with vraptor.
Could you explain?
[] s. ..
Hi mahh,
You can store the data in the session.
ZK - Open Source Ajax Java Framework
Hello everybody
I'm trying to integrate ZK with VRaptor (a MVC controller, like Struts). ZK handles the AJAX requests in Composers, and VRaptor handles page requests.
VRaptor is simple and agile to use, it uses a lot of dependency injection and convention over configuration. One example, related to my problem, is this:
If I were using JSP, I could have this form:
<form action="<c:url value="/clients/add/"/>"> Name: <input type="text" name="client.name" /><br/> Descrição: <input type="text" name="client.id" /><br/> <input type="submit" /> </form>And when the request is made, VRaptor catches the values, and give me the Client ready to use:
@Path("/clients/") public class ClientsController{ @Path("/add/") public void add(Client c){ //do stuff } }He also do the inverse, I could return a Client in the add() method, and VRaptor adds it to the http request so it's available on the page through EL. But that's not the problem.
I just can't find a way to put the client in the requisition. This is the code I have now:
The page:
... <row>Name: <textbox id="clientName" name="client.name" value="${client.name}" /></row> <row>ID: <textbox id="clientId" name="client.id" value="${client.id}" /></row> ...The ajax handler:
public void onClick$save(Event evt){ Client a = new Client(); c.setName(clientName.getValue()); evt.getPage().setVariable("client", c); //didn't work Executions.sendRedirect("/client/view/"); }/client/view/ redirects to the same page, but VRaptor should get the Client in the requisition that came from onClick$save(), but it keeps coming null.
So, what am I doing wrong? How do I get ZK to send the information attached to the HTTP requisition like if it was a JSP form?
The way I found to get this done was using URI parameters, so I send /clients/view/3 and I can get this in @Path("/add/{id}") add(int id), in my Controller. So I get this ID and search for the Client I just saved instead of getting it from the HTTP request.
I may be saying a lot of nonsense here, if that's the case, please let me know :)