1 14 package org.wings.plaf.css.msie; 15 16 import java.io.IOException ; 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 ButtonCG extends org.wings.plaf.css.ButtonCG implements SParentFrameListener { 34 35 private static final String FORMS_JS = (String ) SessionManager 36 .getSession().getCGManager().getObject("JScripts.form", 37 String .class); 38 39 42 protected void writeButtonStart(final Device device, final SAbstractButton comp) throws IOException { 43 device.print("<button onclick=\"addHiddenField(this.form,'"); 44 device.print(comp.getParentFrame().getEventEpoch()); 45 device.print(SConstants.UID_DIVIDER); 46 device.print(SConstants.IEFIX_BUTTONACTION); 47 device.print("','"); 48 device.print(comp.getName()); 49 device.print("')\""); 50 } 51 52 protected void writeLinkStart(Device device, RequestURL addr) throws IOException { 53 device.print("<a onclick=\"javascript:location.href='"); 54 Utils.write(device, addr.toString()); 55 device.print("';\""); 56 } 57 58 public void installCG(SComponent component) { 59 super.installCG(component); 60 component.addParentFrameListener(this); 61 } 62 63 public void parentFrameAdded(SParentFrameEvent e) { 64 SFrame parentFrame = e.getParentFrame(); 65 ClasspathResource res = new ClasspathResource(FORMS_JS, "text/javascript"); 66 String jScriptUrl = SessionManager.getSession().getExternalizeManager().externalize(res, ExternalizeManager.GLOBAL); 67 parentFrame.addHeader(new Script("text/javascript", new DefaultURLResource(jScriptUrl))); 68 } 69 70 public void parentFrameRemoved(SParentFrameEvent e) { 71 } 72 73 } 74 | Popular Tags |