Нужна помощь Я хочу получить доступ к некоторому компоненту из login.zul, который включен в файл main.zul, я хочу сохранить свой user_id в сериализации класса, когда пользователь вошел в систему, вот мой код login.zul:NullPointerException, когда компонент доступа с использованием пути Путь ("// pg_id/window") в zul файле
<?page id="pg_login"?>
<zk xmlns="http://www.zkoss.org/2005/zul">
<window id="wlogin" title="Login" style="border:0px;background:#FF9900;" width="350px" height="340px" closable="false" maximizable="false" mode="modal" maximized="false" position="center" apply="id.my.berkah.web.dmt.controller.LoginCTRL" sizable="false">
<grid height="100%" width="100%" style="border:0px;background:#FF0000;" oddRowSclass="non-odd">
<columns>
<column align="right" width="120px" style="border:0px;"/>
<column align="left" width="216px" style="border:0px;"/>
</columns>
<rows >
<row spans="2">
<image src="img/LogoDmt1.png" height="180px" width="330px"/>
<!--<label value="DMT" />-->
</row>
<row style="border:0px;background:#FF0000;">
<label style="color: white" value="User :"/>
<textbox id="txtUser" width="200px" style="text-transform: uppercase" height="18px"/>
</row>
<row style="border:0px;background:#FF0000;">
<label style="color: white" value="Password :"/>
<textbox id="txtPassword" type="password" width="200px" height="18px"/>
</row>
<row visible="false">
<textbox id="status" value="N"/>
<textbox id="sessionId"/>
</row>
<row spans="5" align="left">
<hbox>
<div width="115px"></div>
<button id="btnlogin" label="Login" image="/img/Lock24.png" height="35px" width="100px"/>
<button id="btncancel" label="Cancel" image="/img/Logout24.png" height="35px" width="100px"/>
</hbox>
</row>
</rows>
</grid>
</window>
</zk>
и вот мой main.zul:
<?page id="pg_index" cacheable="false" language="xul/html" zscriptLanguage="Java" contentType="text/html;charset=UTF-8"?>
<zk xmlns="http://www.zkoss.org/2005/zul">
<style>
.nav_toolbar .z-toolbarbutton-content i { font-size: 20px;}
.nav_tabs .z-tabpanel { padding: 0; border-bottom: 0 none;}
.nav_tabs .z-tabpanels .z-toolbarbutton-content { padding: 4px;}
.nav_category { cursor:pointer; }
.nav_text { color: #696569; font-size : 24px; font-weight: bold;}
</style>
<style>
.labelstyle {
font-weight: bold;
font-size : 30px;
font-align : center;
font-family: 'Times New Roman';
color: green;
}
</style>
<div id="container" height="50px" width="100%">
<borderlayout>
<center>
<!--<label id="lblx" value="DATA MEDIA TELEKOMUNIKASI" sclass="labelstyle"/>-->
</center>
</borderlayout>
</div>
<toolbar sclass="nav_toolbar">
<toolbarbutton target="_zkdemo" style="color: #3a92c8;"
iconSclass="z-icon-twitter-square" href="http://twitter.com/zkoss" />
<toolbarbutton target="_zkdemo" style="color: #3b5998;"
iconSclass="z-icon-facebook-square" href="http://[email protected]" />
<toolbarbutton target="_zkdemo" style="color: #696569;"
iconSclass="z-icon-github-square" href="https://github.com/zkoss/" />
</toolbar>
<separator height="5px">
</separator>
<!--<include id="includeLogin" mode="instant" src="login.zul" />-->
<window id="win_main">
<zscript><![CDATA[
void updateCategory() {
//includeID.setSrc("/findMonitor.zul");
}
void updateSubPage() {
iframe.setSrc("/login.zul");
}
void addListTrx() {
iframe.setSrc("/list_assign_msisdn_dpa.zul");
}
]]>
</zscript>
<borderlayout height="650px" >
<west title="Menu" size="20%" flex="true" maxsize="200" splittable="true" autoscroll="true" collapsible="true">
<div width="50%" height="300px" style="background:#24a0aa;">
<hbox>
<navbar id="vn" orient="vertical" collapsed="false" width="300px" >
<navitem label="Home" iconSclass="z-icon-home" />
<nav label="Get Started" iconSclass="z-icon-th-list" badgeText="3" >
<navitem label="Step One" />
<navitem label="Step Two" />
<navitem label="Step Three" />
</nav>
<navitem label="About" iconSclass="z-icon-flag"/>
<navseparator/>
<nav label="Contact" iconSclass="z-icon-envelope" badgeText="5">
<navitem label="Reply" iconSclass="z-icon-reply" />
<navitem label="Reply all" iconSclass="z-icon-reply-all"/>
<navitem label="Inbox" iconSclass="z-icon-inbox"/>
<navitem label="Edit" iconSclass="z-icon-edit"/>
<navseparator/>
<nav label="Settings" iconSclass="z-icon-cog" badgeText=">>">
<navitem label="Edit profile" iconSclass="z-icon-user"/>
<navitem label="Keyboard shortcuts" iconSclass="z-icon-keyboard-o"/>
<navitem label="Change password" iconSclass="z-icon-key"/>
</nav>
</nav>
<navitem id="menuList" label="redirect" context="editPopup" onClick="Executions.getCurrent().sendRedirect("list_assign_msisdn_dpa.zul", "_blank");"/>
<navitem label="href" context="editPopup" onClick="updateSubPage()"/>
<navitem label="Freeze" iconSclass="z-icon-asterisk" onClick="addListTrx()" />
<navitem label="Logout" onClick="updateSubPage()" iconSclass="z-icon-power-off"/>
</navbar>
<menupopup id="editPopup">
<menuitem label="Buka di tab baru" onClick="Executions.getCurrent().sendRedirect("list_assign_msisdn_dpa.zul", "_blank");" />
<menuitem label="Help" onClick="Messagebox.show("Silahkan hubungi kantor polisi")"/>
</menupopup>
</hbox>
</div>
</west>
<center flex="true" autoscroll="true" style="background:#5C899B;">
<borderlayout>
<center title="Content Area" vflex="true" >
<iframe id="iframe"
width="100%" height="700px" style="border: 1px solid gray" />
</center>
<south id="planFrame" vflex="true">
</south>
</borderlayout>
</center>
<north>
<label id="g1" value="User Name" style="text-transform: uppercase;color:white;font-weight:bold;cursor:hand;cursor:pointer" height="50px" sclass="bawah" tooltiptext="Click Here for User Information and Request BU."/>
</north>
</borderlayout>
</window>
<include id="includeID" mode="instant" src="/login.zul" />
</zk>
я не могу получить txtpassword с этим Java-код:
DMTImplements imp=new DMTImplements();
Path parent = new Path("//pg_login/wlogin");
Textbox pass=(Textbox)new Path(parent,"txtPassword").getComponent();
Исключение сообщение:
Exception in thread "main" java.lang.NullPointerException
at org.zkoss.zk.ui.Path.getComponent0(Path.java:114)
at org.zkoss.zk.ui.Path.getComponent(Path.java:66)
что я должен делать ??
хорошо страницы идентификатор 'pg_index' и окно идентификатор' win_main' изменить свой второй ряд соответственно – AlexGreg
я имею в виду win_login извините, я хочу GetComponent() из win_login, который является txtPassword –
add login.zul тоже – AlexGreg