1 38 package com.gargoylesoftware.htmlunit.html; 39 40 import java.io.IOException ; 41 import java.net.MalformedURLException ; 42 import java.net.URL ; 43 import java.util.Map ; 44 45 import com.gargoylesoftware.htmlunit.Page; 46 import com.gargoylesoftware.htmlunit.SubmitMethod; 47 import com.gargoylesoftware.htmlunit.WebClient; 48 import com.gargoylesoftware.htmlunit.WebRequestSettings; 49 import com.gargoylesoftware.htmlunit.WebWindow; 50 51 59 public class HtmlArea extends FocusableElement { 60 61 62 public static final String TAG_NAME = "area"; 63 64 70 public HtmlArea( final HtmlPage page, final Map attributes ) { 71 super( page, attributes ); 72 } 73 74 77 public String getTagName() { 78 return TAG_NAME; 79 } 80 81 93 protected Page doClickAction(final Page defaultPage) throws IOException { 94 final HtmlPage enclosingPage = getPage(); 95 final WebClient webClient = enclosingPage.getWebClient(); 96 97 final String href = getHrefAttribute(); 98 if( href != null && href.length() > 0 ) { 99 final URL url; 100 try { 101 url = enclosingPage.getFullyQualifiedUrl( getHrefAttribute() ); 102 } 103 catch( final MalformedURLException e ) { 104 throw new IllegalStateException ( 105 "Not a valid url: " + getHrefAttribute() ); 106 } 107 final WebRequestSettings settings = new WebRequestSettings(url, 108 SubmitMethod.getInstance(getAttributeValue("method"))); 109 final WebWindow webWindow = enclosingPage.getEnclosingWindow(); 110 return webClient.getPage( 111 webWindow, 112 enclosingPage.getResolvedTarget(getTargetAttribute()), 113 settings); 114 } 115 else { 116 return defaultPage; 117 } 118 } 119 120 128 public final String getShapeAttribute() { 129 return getAttributeValue("shape"); 130 } 131 132 133 141 public final String getCoordsAttribute() { 142 return getAttributeValue("coords"); 143 } 144 145 146 154 public final String getHrefAttribute() { 155 return getAttributeValue("href"); 156 } 157 158 159 167 public final String getNoHrefAttribute() { 168 return getAttributeValue("nohref"); 169 } 170 171 172 180 public final String getAltAttribute() { 181 return getAttributeValue("alt"); 182 } 183 184 185 193 public final String getTabIndexAttribute() { 194 return getAttributeValue("tabindex"); 195 } 196 197 198 206 public final String getAccessKeyAttribute() { 207 return getAttributeValue("accesskey"); 208 } 209 210 211 219 public final String getOnFocusAttribute() { 220 return getAttributeValue("onfocus"); 221 } 222 223 224 232 public final String getOnBlurAttribute() { 233 return getAttributeValue("onblur"); 234 } 235 236 237 245 public final String getTargetAttribute() { 246 return getAttributeValue("target"); 247 } 248 } 249 | Popular Tags |