JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » AJAX討論區 » ZK  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
作者 Re:我的zk程式, 會出現 Can't execute code from a freed script [Re:zanyking]
ethan_victory





發文: 49
積分: 0
於 2009-02-03 18:06 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
感謝各位大大的協助
小弟程式中做了幾個模組, 這個登入登出模組就會發生這個can't execute code的問題(登入後,登出,再登入一次, 就出現)

index.zul
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?page id="retrain"?>
<zk>
  <columnlayout>
    <columnchildren width="25%">
 
      <panel>
        <panelchildren style="margin: 5px 5px;">
          <include src="/user/user_pie.zul" />
          <include src="/user/user_login.zul" />
          <include src="/user/user_list.zul" />
        </panelchildren>
      </panel>
    </columnchildren>
    <columnchildren width="75%">
      <panel>
        <panelchildren style="margin: 5px 15px;">
          <include id="loginedInfo" />
          <include src="/event/event_list.zul" />
        </panelchildren>
      </panel>
    </columnchildren>
  </columnlayout>
</zk>


user_login.zul
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?page id="userLogin"?>
<groupbox id="root" mold="3d">
  <tabbox tabscroll="false" width="240px"
    apply="action.LoginComposer">
    <tabs id="loginTabs">
      <tab id="loginView" label="登入" />
      <tab id="forgetView" label="忘記密碼" />
      <tab id="applyView" label="註冊" />
      <tab id="editView" label="修改個人資料" visible="false" />
    </tabs>
    <tabpanels>
      <tabpanel id="loginTabpanel">
        <div id="loginDiv">
        <grid id="loginGrid">
          <rows>
            <row>
              帳號:
              <textbox id="account" />
            </row>
            <row>
              密碼:
              <hbox>
                <textbox id="password" type="password"
                  width="70px"/>
                <button id="login" label="登入"></button>
              </hbox>
            </row>
          </rows>
        </grid>
        </div>
        <div id="loginedDiv">
          <label id="loginLabel" style="color:red;"/>
          <button id="logoutBtn" label="登出" />
        </div>
      </tabpanel>
      <tabpanel id="forgetTabpanel">
        <grid>
          <rows>
            <row><hbox>
              E-mail:
              <textbox id="email" width="120px"
                constraint="/.+@.+\.[a-z]+/: Please enter an e-mail address,no empty" />
              <button id="forgetBtn" label="送出" /></hbox>
            </row>
          </rows>
        </grid>
      </tabpanel>
    </tabpanels>
  </tabbox>
</groupbox>


LoginComposer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package action;
 
import java.util.List;
import hbm.*;
import org.zkoss.zk.ui.*;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.*;
 
import utils.ConstantData;
 
public class LoginComposer extends GenericForwardComposer {
 
  Tab loginView;
  Tab forgetView;
  Tab applyView;
  Tab editView;
  Button login;
  Textbox account;
  Textbox password;
  Textbox email;
  Button logoutBtn;
  Label loginLabel;
  Grid loginGrid;
  Div loginedDiv, loginDiv;
  public void onClick$forgetBtn(Event event) {
    try {
      Messagebox.show("密碼已寄送,請稍送查看您的信箱!", "密碼寄送", Messagebox.OK, Messagebox.INFORMATION);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
  public void onClick$editView(Event event) {
    loginView.setSelected(true);
    Window win = (Window) Executions.createComponents(
        "/user/user_add.zul", null, null);
    win.setTitle("修改個人資料");
    try {
      win.doModal();
      win.focus();
    } catch (SuspendNotAllowedException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
  public void onClick$logoutBtn(Event event) {
    Executions.getCurrent().getDesktop().getSession().removeAttribute("userInfo");
    forgetView.setVisible(true);
    applyView.setVisible(true);
    editView.setVisible(false);
    loginGrid.setVisible(true);
    account.setValue("");
    password.setValue("");
    loginedDiv.setVisible(false);
    loginDiv.setVisible(true);
    ((Include)ConstantData.getComponentByPath("//retrain/loginedInfo")).setSrc("");
 
  }
  public void onSelect$applyView(Event event){
    ConstantData.doModelWindow("/user/user_add.zul", null, null);
    loginView.setSelected(true);
  }
  public void onClick$login(Event event) {
    UserInfo userInfo = new UserInfo();
    userInfo.setAccount(account.getValue());
    userInfo.setPassword(password.getValue());
    UserInfoDAO dao = new UserInfoDAO();
    List list = dao.findByExample(userInfo);
    if(list!=null && list.size()==1){
      userInfo = (UserInfo)list.get(0);
      Executions.getCurrent().getDesktop().getSession().setAttribute("userInfo", userInfo);
      setLoginLayout();
    }else{
      try {
        Messagebox.show("帳號或密碼有誤!", "登入", Messagebox.OK, Messagebox.ERROR);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      account.focus();
    }
    
  }
  private void setLoginLayout(){
    if(Executions.getCurrent().getDesktop().getSession().getAttribute("userInfo") != null){
      UserInfo userInfo = (UserInfo)Executions.getCurrent().getDesktop().getSession().getAttribute("userInfo");
      loginLabel.setValue("歡迎"+userInfo.getNickName()+"登入!");
      forgetView.setVisible(false);
      applyView.setVisible(false);
      editView.setVisible(true);
      loginGrid.setVisible(false);
      loginedDiv.setVisible(true);
      loginDiv.setVisible(false);
      ((Include)ConstantData.getComponentByPath("//retrain/loginedInfo")).setSrc("/logined/logined_info.zul");
    }
  }
  public void doAfterCompose(Component comp) throws Exception {
    super.doAfterCompose(comp);
    loginedDiv.setVisible(false);
    loginDiv.setVisible(true);
    setLoginLayout();
  }
  public LoginComposer() {
    
  }
}


reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
995 我的zk程式, 會出現 Can't execute code from a freed script ethan_victory 122 2009-02-03 16:34
840 Re:我的zk程式, 會出現 Can't execute code from a freed script b8201032 190 2009-02-03 17:17
831 Re:我的zk程式, 會出現 Can't execute code from a freed script zanyking 26 2009-02-03 17:19
978 Re:我的zk程式, 會出現 Can't execute code from a freed script ethan_victory 5240 2009-02-03 18:06
770 Re:我的zk程式, 會出現 Can't execute code from a freed script atticcat 146 2009-02-05 09:39
892 Re:我的zk程式, 會出現 Can't execute code from a freed script ethan_victory 208 2009-02-06 15:26
» JWorld@TW »  AJAX討論區 » ZK

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8