View Javadoc
1 /* 2 * Angkor Web Framework 3 * 4 * Distributable under LGPL license. 5 * See terms of license at gnu.org. 6 */ 7 8 package com.tirsen.angkor.widget; 9 10 import com.tirsen.angkor.RenderContext; 11 import com.tirsen.angkor.Component; 12 import com.tirsen.angkor.event.Action; 13 import com.tirsen.angkor.event.ActionListener; 14 import com.tirsen.angkor.event.ActionSource; 15 import com.tirsen.angkor.event.ActionSourceHelper; 16 17 import java.io.IOException; 18 19 /*** 20 * <!-- $Id: ImageButton.java,v 1.4 2002/10/13 19:59:23 tirsen Exp $ --> 21 * <!-- $Author: tirsen $ --> 22 * 23 * @author Jon Tirs´n (tirsen@users.sourceforge.net) 24 * @version $Revision: 1.4 $ 25 */ 26 public class ImageButton extends Component implements ActionSource 27 { 28 private ActionSourceHelper actionSourceHelper = new ActionSourceHelper(this); 29 private String imageURL; 30 31 public ImageButton(String id) 32 { 33 super(id); 34 } 35 36 public ImageButton() 37 { 38 } 39 40 public ImageButton(Action action) 41 { 42 setAction(action); 43 } 44 45 public void setAction(Action action) 46 { 47 actionSourceHelper.setAction(action); 48 } 49 50 public Action getAction() 51 { 52 return actionSourceHelper.getAction(); 53 } 54 55 public void addActionListener(ActionListener listener) 56 { 57 actionSourceHelper.addActionListener(listener); 58 } 59 60 public void removeActionListener(ActionListener listener) 61 { 62 actionSourceHelper.removeActionListener(listener); 63 } 64 65 public void signalActionEvent() 66 { 67 actionSourceHelper.signalActionEvent(); 68 } 69 70 public void setImageURL(String label) 71 { 72 this.imageURL = label; 73 } 74 75 public boolean isParsing() 76 { 77 return true; 78 } 79 80 public String getImageURL() 81 { 82 String resultingImageURL = null; 83 84 if (imageURL != null) 85 { 86 resultingImageURL = imageURL; 87 } 88 else 89 { 90 if (getAction() != null) resultingImageURL = (String) getAction().getValue(Action.IMAGE_URL); 91 } 92 93 return resultingImageURL; 94 } 95 96 public String toString() 97 { 98 return getClass().getName() + "[" + getAction() + "]"; 99 } 100 101 public void render(RenderContext context) throws IOException 102 { 103 if (isVisible()) 104 { 105 context.startTag("INPUT name=\"" + uniqueId(context) + "\" border=\"0\" type=\"image\" src=\"" + getImageURL() + "\""); 106 context.registerParsingComponent(this); 107 } 108 } 109 110 public void parse(RenderContext context) 111 { 112 super.parse(context); 113 if (context.getRequestParameter(getId() + ".x") != null) 114 { 115 actionSourceHelper.signalActionEvent(context); 116 } 117 } 118 }

This page was automatically generated by Maven