ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

How to access zk UI component from zscript

aks
1 Feb 2012 10:19:03 GMT
1 Feb 2012 10:19:03 GMT

My jsp file code is as follows-
MyFile.jsp


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <%@ taglib uri="http://www.zkoss.org/jsp/zul" prefix="zk" %> 

<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<html>
<head>


<zk:page>
			<zk:zscript>						
					Row rw=new Row();
					Label l1=new Label((requestScope.get("pid")).toString());
					Label l2=new Label((requestScope.get("spec")).toString());
					Label l3=new Label((requestScope.get("qt")).toString());
					Label l4=new Label((requestScope.get("pno")).toString());
					System.out.println("...."+requestScope.get("pid"));	
									
					rw.appendChild(l1);
					rw.appendChild(l2);
					rw.appendChild(l3);
					rw.appendChild(l4);
										
					Rows rws= (Rows) Path.getComponent("//p3/winGrid/Proper/rowsPriceList");
					System.out.println(rws);
			</zk:zscript>
		</zk:page>
</head>
<body>
<div class="bottomarea">				
				<table id="PropertiesTable" border="1" class="style1" style="overflow: scroll;">
					<tr>
						<th width="20%">Part Id</th>
						<th	width="50%">Specification</th>
						<th width="20%">Quantity</th>
						<th width="30%">Part Number</th>
					</tr>
				</table>			
				<zk:page id="p3">
					<zk:window id="winGrid">					
					<zk:grid id="Proper" fixedLayout="true" mold="paging" pageSize="6" pagingPosition="top" visible="true" width="100%">
						<zk:auxhead>
							<zk:auxheader id="lblNewReg" colspan="6" style="background-color: #D6DCDE;font-size :25px;border:0px"/>
						</zk:auxhead>
						<zk:columns>
							<zk:column label="Part Id" sort="auto" width="20%" />
							<zk:column label="Specification" width="40%" />
							<zk:column label="Quantity" sort="auto" width="10%" />
							<zk:column label="Part Number" sort="auto" width="20%" />
						</zk:columns>
						<zk:rows id="rowsPriceList">
						</zk:rows>
					</zk:grid>	
					</zk:window>	
					<zk:vbox id="vboxCart" width="100%" align="start">
						<zk:button id="addCartBtn1" src="/img/add-cart.png" tooltiptext="Add to Cart" label="Add to Cart" disabled="true"/>
						<zk:space height="1px"/>
					</zk:vbox>										
				</zk:page>				
			</div> <!--end bottomarea-->
</body>
</html>		




As in above code i want to add row to rows of zk grid ..
But in zscript i m not getting "rowsPriceList" of zk grid, i m getting null there..
Is it right way to do so or is there any other way for the same..
Please provide me with solution..

Thanks in advance

aks
1 Feb 2012 10:22:02 GMT
1 Feb 2012 10:22:02 GMT

In above code at line

Rows rws= (Rows) Path.getComponent("//p3/winGrid/Proper/rowsPriceList");


I m getting null.. Why? how to solve this????

matthewgo
6 Feb 2012 08:15:07 GMT
6 Feb 2012 08:15:07 GMT

Hi aks,
Please notice the sequence of zscript tag in zul, or the ID cannot find at that time :

....
...
<zk:vbox id="vboxCart" width="100%" align="start">
	<zk:button id="addCartBtn1" src="/img/add-cart.png" tooltiptext="Add to Cart" label="Add to Cart" disabled="true"/>
	<zk:space height="1px"/>
</zk:vbox>
<zk:zscript>						
					Row rw=new Row();
					Label l1=new Label((requestScope.get("pid")).toString());
					Label l2=new Label((requestScope.get("spec")).toString());
					Label l3=new Label((requestScope.get("qt")).toString());
					Label l4=new Label((requestScope.get("pno")).toString());
					System.out.println("...."+requestScope.get("pid"));	
									
					rw.appendChild(l1);
					rw.appendChild(l2);
					rw.appendChild(l3);
					rw.appendChild(l4);
										
					Rows rws= (Rows) Path.getComponent("//p3/winGrid/Proper/rowsPriceList");
					System.out.println(rws);
</zk:zscript>
</zk:page>				
			</div> <!--end bottomarea-->
</body>
</html>