KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > plaf > css > msie > CheckBoxCG


1 /*
2  * $Id: CheckBoxCG.java,v 1.5 2005/06/07 12:55:59 neurolabs Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.plaf.css.msie;
15
16 import java.io.IOException JavaDoc;
17
18 import org.wings.RequestURL;
19 import org.wings.SAbstractButton;
20 import org.wings.SComponent;
21 import org.wings.SConstants;
22 import org.wings.SFrame;
23 import org.wings.event.SParentFrameEvent;
24 import org.wings.event.SParentFrameListener;
25 import org.wings.externalizer.ExternalizeManager;
26 import org.wings.header.Script;
27 import org.wings.io.Device;
28 import org.wings.plaf.css.Utils;
29 import org.wings.resource.ClasspathResource;
30 import org.wings.resource.DefaultURLResource;
31 import org.wings.session.SessionManager;
32
33 public class CheckBoxCG extends org.wings.plaf.css.CheckBoxCG implements SParentFrameListener {
34     private static final String JavaDoc FORMS_JS = (String JavaDoc) SessionManager
35     .getSession().getCGManager().getObject("JScripts.form",
36             String JavaDoc.class);
37
38     /* (non-Javadoc)
39      * @see org.wings.plaf.css.ButtonCG#writeButtonStart(org.wings.io.Device, org.wings.SAbstractButton)
40      */

41     protected void writeButtonStart(Device device, SAbstractButton comp) throws IOException JavaDoc {
42         device.print("<button onclick=\"addHiddenField(this.form,'");
43         device.print(comp.getParentFrame().getEventEpoch());
44         device.print(SConstants.UID_DIVIDER);
45         device.print(SConstants.IEFIX_BUTTONACTION);
46         device.print("','");
47         device.print(comp.getName());
48         device.print("')\"");
49     }
50
51     /* (non-Javadoc)
52      * @see org.wings.plaf.css.CheckBoxCG#writeLinkStart(org.wings.io.Device, org.wings.RequestURL)
53      */

54     protected void writeLinkStart(final Device device, RequestURL addr) throws IOException JavaDoc {
55         device.print("<a onclick=\"javascript:location.href='");
56         Utils.write(device, addr.toString());
57         device.print("';\"");
58     }
59
60     public void installCG(SComponent component) {
61         super.installCG(component);
62         component.addParentFrameListener(this);
63     }
64
65     public void parentFrameAdded(SParentFrameEvent e) {
66         SFrame parentFrame = e.getParentFrame();
67         ClasspathResource res = new ClasspathResource(FORMS_JS, "text/javascript");
68         String JavaDoc jScriptUrl = SessionManager.getSession().getExternalizeManager().externalize(res, ExternalizeManager.GLOBAL);
69         parentFrame.addHeader(new Script("text/javascript", new DefaultURLResource(jScriptUrl)));
70     }
71
72     public void parentFrameRemoved(SParentFrameEvent e) {
73     }
74
75 }
76
Popular Tags