-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4496832
By: andy-susanto
hai,
i read a devguide. but i still do not understand how to do it ?, what i know that must use a macro file.
is anyone will help me to provide an example ? i need that because i do not want the parameter exist on the url
TIA,
andy susanto
Hi,
Try to store the data in session or component.
In your case, the request is different from you set.
/Jumper
It is not clear at all, I wont to pass java object with link. I use grid, and I have link to another page which expected this object.
java
<code>
MyRowRender implements RowRenderer{
...
public void render(Row row, Object data) throws Exception {
....
Person person_N = (Person) data; // not null
Toolbarbutton link_person = new Toolbarbutton();
link_person.setHref("Person_CRUD.zul");
link_person.setLabel("Person_CRUD.zul");
link_person.setAttribute("oseba_N_atr", person_N); // no forward, user should click on this link and ZUL get Person
link_person.setParent(row);
....
}
}
<code>
Person_CRUD.zul
<code>
<zscript><![CDATA[
Person oseba_N_atr = (Person) Executions.getCurrent().getAttribute("oseba_N_atr");
System.out.print("\n oseba_N_atr="+oseba_N_atr);
]]></zscript>
</code>
So Person oseba_N_atr is always null!!
I'm doing something very wrong whit this ZK framework
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4506330
By: andy-susanto
hai Chen,
thanks for your information. now i can move on to my next step
i will remember that
Executions.sendRedirect() or any onXXX event is fired, the previous request no longer exists, so you cannot get the attribute saved in the previous request.
Regards,
andy susanto
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4506131
By: jumperchen
Hi Andy,
Executions.getCurrent().setAttribute() is available in the request scope.
If you use Executions.sendRedirect() or any onXXX event is fired, the previous request no longer exists, so you cannot get the attribute saved in the previous request.
So, you should store the attribute into the session or other phase scope.
Regards,
Jumper
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4504635
By: andy-susanto
Hai Chen,
i read a javadoc but i cannot find about how to pass a variable between zul file.
this is my a zul and java file that will call another zul file when toolbarbutton click
first.zul
<?init class="ibs.transaksi.spa.locker.Locker" arg0="locker" ?> <toolbarbutton id="${each.lockerNo}" onClick="new ibs.transaksi.spa.locker.Locker().test(self)"
label="${each.lockerNo}" forEach="${locker}"
style="font:30px/1.2em Arial, Verdana, sans-serif;"/>
package ibs.transaksi.spa.locker;
import html.tag.NewLine;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.util.Initiator;
import org.zkoss.zul.Toolbarbutton;
import database.AutoReconnect;
public class Locker extends LockerObj implements Initiator{
public void doInit(Page page,Object[] args){
List tabLabel = new LinkedList();
Connection Con = null;
PreparedStatement pstmtListTransLocker = null;
try{
Con = AutoReconnect.getConection();
StringBuffer sbSQLStatement = new StringBuffer("SELECT LOCKER_NO,LOCKER_ID ");
sbSQLStatement.append("FROM LOCKER ");
sbSQLStatement.append("WHERE LOCKER_TYPE = 'M' AND LOCKER_SUSPEND=0 ");
sbSQLStatement.append("ORDER BY LOCKER_NO ");
pstmtListTransLocker = Con.prepareStatement(sbSQLStatement.toString());
ResultSet rs = pstmtListTransLocker.executeQuery();
while (rs.next()){
tabLabel.add(new
LockerObj(rs.getString("LOCKER_ID"),rs.getString("LOCKER_NO")));
}
}
catch(SQLException error){
System.err.print("Open Connection Gagal ".concat(error.getMessage()).concat(NewLine.CodeBreak()));
}finally{
page.setVariable((String) args[0], tabLabel);
//Close Connection
if (Con != null){
try{
Con.close();
Con = null;
}
catch(SQLException error){
System.err.print("Close Connection Gagal ".concat(error.getMessage()).concat(NewLine.CodeBreak()));
}
}
}
}
public void doCatch(Throwable ex){
}
public void doFinally(){
}
public void doAfterCompose(Page arg0) throws Exception {
// TODO Auto-generated method stub
}
public void test(Toolbarbutton a){
StringBuffer sbUrl= new StringBuffer("/forms/display/test.zul");
Executions.getCurrent().setAttribute("key", a.getId());
Executions.sendRedirect(sbUrl.toString());
}
}
second.zul( this file show an attribute which user click from first.zul) <?init class="ibs.mainapp" arg0="rt" ?> <label value="${rt}"/>
package ibs;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.util.Initiator;
public class mainapp implements Initiator,Controller {
public void doInit(Page page,Object[] args){
String test = page.getAttributes().toString();
System.out.println(page.getVariable("key"));
page.setVariable((String) args[0], test);
}
public void doAfterCompose(Page page) throws Exception{}
public void doCatch(Throwable throwable){}
public void doFinally(){}
public ModelAndView handleRequest(HttpServletRequest req, HttpServletResponse
res)
throws ServletException,IOException{
return new ModelAndView("/forms/display/display.zul");
}
}
Chen can you help me how can i achieve my goal ?
TIA,
andy susanto
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4499004
By: jumperchen
Hi Andy,
You mistook my meaning.
Try this,
In other1.zul file,
<zscript>
Executions.getCurrent().setAttribute("key1", "val1"); Executions.getCurrent().forward("/other2.zul");
</zscript>
In other2.zul file,
<zscript>
Executions.getCurrent().getAttribute("key");
</zscript>
Please take a look at the API -
http://www.zkoss.org/javadoc/2.4.1/zk/org/zkoss/zk/ui/Execution.html#getAttribut
e(java.lang.String)
/Jumper
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4498944
By: rudi_black
hi andy,
i'm not sure if i'm i'm right but u r using implements instead of extends for your class. to my knowledge, implements is used for interfaces while extends is for class (again i may be wrong).
in my macro components (java class) ... i always extends the basic class and i got no problem what so ever w/ the methods, properties etc...
good luck
-rudi-
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4498515
By: andy-susanto
hai Chen,
zul file
<?init class="ibs.mainapp" arg0="key1" ?> <label value="${key1}"/>
i am sorry i try create a java code like this
public class mainapp implements Initiator,Controller{
public void doInit(Page page,Object[] args){
String key1 = request.getAttribute();
}
public void doAfterCompose(Page page) throws Exception{}
public void doCatch(Throwable throwable){}
public void doFinally(){}
}
the problem is request method can not be resolved. Could you give me another an example ?
TIA,
andy susanto
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4498203
By: andy-susanto
hai Jumper,
how other.zul get value of "key1" ?
TIA,
andy susanto
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4498243
By: jumperchen
Hi Andy,
The Executions.getCurrent().setAttribute() is the same with request.setAttribute(), so you can use the Executions.getCurrent().getAttribute() or request.getAttribute().
/Jumper
Asked: 2007-09-02 04:28:59 +0800
Seen: 1,921 times
Last updated: Apr 10 '09