reduce my code

asked 2010-03-29 09:15:27 +0800

saad gravatar image saad
207 1 2

hi all
i have my page loggin zul:

<?xml version="1.0" encoding="UTF-8"?>
<?page title="MyFirstZKProject" style="text-align:center;"?>
<p:zk xmlns:p="http://www.zkoss.org/2005/zul">
<p:window title="Omnidata" width="100%" height="768px"
style=" background: #EDF7F2; border: 4px groove #003366; text-align: center;"
id="logWin" use="com.action.Login"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">

<!-- CSS -->
<p:style src="/css/main.css" dynamic="true"/>
<p:div align="center">
<p:vbox spacing="2em" width="500px" style="text-align: center;">
<!-- IMAGE -->
<p:div align="center">
<p:image style="border: 3px groove #000066;" src="/page/img/omnidata.JPG"/>
<!-- Window LOGIN -->
<p:window title="Login" width="500px" id="loginDlg" onOK="login()" sclass="windowStyle" context="ActionPopup">
<p:div align="center">
<!-- TIMER -->
<p:label id="lheure" style="text-align: right;font-size: small;font-weight: bold;color: #cc3333;"/>
<p:timer id="timer" delay="1000" repeats="true" onTimer="lheure.setValue(new Date().toGMTString())"/>
<!-- SEPARATOR -->
<!-- GRID -->
<p:grid width="350px">
<p:column width="30px"/>
<p:column width="60px"/>
<p:column width="120px"/>
<p:image src="/page/img/login.JPG"/>
<p:label value="Login"/>
<p:textbox zclass="mydb" id="userName" width="120px" sclass="windowStyle"/>
<p:row >
<p:image src="/page/img/paswor.JPG"/>
<p:label value="Password"/>
<p:textbox id="password" type="password" width="120px" sclass="windowStyle"/>
<!-- SEPARATOR -->
<!-- BUTTON -->
<p:div style="text-align: center;">
<p:button label="Se connecter" onClick="login()"/>
<!-- SEPARATOR -->
<p:div align="center">
<p:image style="border: 1px groove #000066;" src="/page/img/itarone.jpg"/>
<!-- SEPARATOR -->
<p:zscript> <![CDATA[ userName.focus(); ]]></p:zscript>
<!-- MENU POPUP -->
<p:menupopup id="ActionPopup">
<p:menuitem label="Overlap" onClick="loginDlg.doOverlapped();"/>
<p:menuitem label="Release" onClick="loginDlg.doEmbedded();"/>
<!-- ZSCRIPT -->
void login()
/* parameter */
password = logWin.getFellow("loginDlg").getFellow("password");
userName = logWin.getFellow("loginDlg").getFellow("userName");
emptyConstraint = SimpleConstraint.getInstance("no empty");

/* we run getValue to validate */

/* we run function from com.action.Login.java */
logWin.login(userName, password);
/* we remove "user" from session */

and i want reduce the code by facotorizing it
please can you suggeste me way so i can minimize the nombre of lines of codes
so my zul can be light on lines of code
thx for help

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2010-03-29 10:31:45 +0800

caclark gravatar image caclark
1753 2 5

I can't suggest anything because it's unreadable...if you surround code fragments with [ c o d e ] and [ / c o d e] without the spaces, it will show your code formatted...

link publish delete flag offensive edit

answered 2010-03-29 10:47:26 +0800

Arsen gravatar image Arsen
381 2

And why do you want to reduce the code? For me it does not seem huge or too complicated. Only may be you can remove p:. But that's all.

link publish delete flag offensive edit

answered 2010-03-30 03:38:52 +0800

saad gravatar image saad
207 1 2

cos when i compare with a login page doing by jsp i find only 24 lines
and here with zk i have 100 lines
so make the comparaition and seeeeee
thx for again

link publish delete flag offensive edit

answered 2010-03-30 04:53:27 +0800

TOtte gravatar image TOtte
93 2

there is almost no real code that could be reduced. You have 11 lines of code, the rest is layout.

link publish delete flag offensive edit

answered 2010-03-30 06:42:43 +0800

saad gravatar image saad
207 1 2

nice answer
so how i can reduce the nomber of lines code of my layout as possible
so the other developper will find that easy to read

link publish delete flag offensive edit

answered 2010-03-31 01:52:38 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

You can use include component to separate them.

link publish delete flag offensive edit

answered 2010-03-31 03:48:07 +0800

saad gravatar image saad
207 1 2

thx for all help

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2010-03-29 09:15:27 +0800

Seen: 599 times

Last updated: Mar 31 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More