List of usage examples for org.apache.wicket Component urlFor
public final CharSequence urlFor(final IRequestHandler requestHandler)
From source file:com.servoy.j2db.server.headlessclient.dataui.WebBaseButton.java
License:Open Source License
public static Object[] getImageDisplayURL(IImageDisplay imageDisplay, boolean appendRandomParam) { String imgURL = null;/* w ww. ja va 2 s .co m*/ Boolean isRandomParamRemoved = Boolean.FALSE; if (imageDisplay instanceof Component) { MediaResource mr; Component imageDisplayComponent = (Component) imageDisplay; if ((mr = imageDisplay.getIcon()) != null) { CharSequence url = imageDisplayComponent.urlFor(ILatestVersionResourceListener.INTERFACE); if (appendRandomParam) { byte[] imageRawData = mr.getRawData(); Checksum checksum = new CRC32(); checksum.update(imageRawData, 0, imageRawData.length); url = url + "&r=" + checksum.getValue(); //$NON-NLS-1$ } else isRandomParamRemoved = Boolean.TRUE; imgURL = Strings.replaceAll(imageDisplayComponent.getResponse().encodeURL(url), "&", "&") //$NON-NLS-1$//$NON-NLS-2$ .toString(); if (imageDisplay.getMediaOptions() != 0 && imageDisplay.getMediaOptions() != 1) { imgURL = imgURL + "&option=" + imageDisplay.getMediaOptions() + "&w=" //$NON-NLS-1$//$NON-NLS-2$ + imageDisplay.getWebBounds().width + "&h=" + //$NON-NLS-1$ imageDisplay.getWebBounds().height; } } else if (imageDisplay.getIconReference() != null && imageDisplay.getMedia() != null) { String solutionName = J2DBGlobals.getServiceProvider().getSolution().getName(); if (imageDisplay.getMediaOptions() != 0 && imageDisplay.getMediaOptions() != 1) { imgURL = imageDisplayComponent.urlFor(imageDisplay.getIconReference()) + "?id=" //$NON-NLS-1$ + imageDisplay.getMedia().getName() + "&s=" + solutionName + //$NON-NLS-1$ "&option=" + //$NON-NLS-1$ imageDisplay.getMediaOptions() + "&w=" + imageDisplay.getWebBounds().width + "&h=" //$NON-NLS-1$//$NON-NLS-2$ + imageDisplay.getWebBounds().height + "&l=" + //$NON-NLS-1$ (imageDisplay.getMedia().getMediaData() != null ? +imageDisplay.getMedia().getMediaData().hashCode() : 0); } else { imgURL = imageDisplayComponent.urlFor(imageDisplay.getIconReference()) + "?id=" //$NON-NLS-1$ + imageDisplay.getMedia().getName() + "&s=" + solutionName + //$NON-NLS-1$ "&l=" //$NON-NLS-1$ + (imageDisplay.getMedia().getMediaData() != null ? +imageDisplay.getMedia().getMediaData().hashCode() : 0); } } else if (imageDisplay.getIconUrl() != null) { imgURL = imageDisplay.getIconUrl(); } else if (imageDisplay.getTextUrl() != null) { String mediaName = imageDisplay.getTextUrl() .substring(MediaURLStreamHandler.MEDIA_URL_DEF.length()); if (mediaName.startsWith(MediaURLStreamHandler.MEDIA_URL_BLOBLOADER)) { ICrypt urlCrypt = null; if (Application.exists()) urlCrypt = Application.get().getSecuritySettings().getCryptFactory().newCrypt(); imgURL = StripHTMLTagsConverter.generateBlobloaderUrl(imageDisplayComponent, urlCrypt, mediaName); } } else if (imageDisplay.getRolloverIconReference() != null || imageDisplay.getRolloverUrl() != null || imageDisplay.getRolloverMedia() != null) { imgURL = imageDisplayComponent.urlFor(TRANSPARENT_IMAGE).toString(); } } return new Object[] { imgURL, isRandomParamRemoved }; }
From source file:com.servoy.j2db.server.headlessclient.dataui.WebBaseButton.java
License:Open Source License
protected static AttributeModifier getImageDisplayRolloverBehavior(final IImageDisplay imageDisplay) { if (imageDisplay instanceof Component) { final Component imageDisplayComponent = (Component) imageDisplay; return new AttributeModifier("onmouseover", true, new Model<String>() { private static final long serialVersionUID = 1L; @Override/* w ww . ja v a 2 s . c o m*/ public String getObject() { String solutionName = J2DBGlobals.getServiceProvider().getSolution().getName(); String url = ""; //$NON-NLS-1$ if (imageDisplay.getRolloverIconReference() != null && imageDisplay.getRolloverMedia() != null) { if (imageDisplay.getMediaOptions() != 0 && imageDisplay.getMediaOptions() != 1) { url = imageDisplayComponent.urlFor(imageDisplay.getRolloverIconReference()) + "?id=" //$NON-NLS-1$ + imageDisplay.getRolloverMedia().getName() + "&s=" + solutionName + "&option=" + //$NON-NLS-2$ imageDisplay.getMediaOptions() + "&w=" + imageDisplay.getWebBounds().width + "&h=" //$NON-NLS-1$//$NON-NLS-2$ + imageDisplay.getWebBounds().height + "&l=" + (imageDisplay.getRolloverMedia().getMediaData() != null ? +imageDisplay.getRolloverMedia().getMediaData().hashCode() : 0); } else { url = imageDisplayComponent.urlFor(imageDisplay.getRolloverIconReference()) + "?id=" //$NON-NLS-1$ + imageDisplay.getRolloverMedia().getName() + "&s=" + solutionName + "&l=" + //$NON-NLS-2$ (imageDisplay.getRolloverMedia().getMediaData() != null ? +imageDisplay.getRolloverMedia().getMediaData().hashCode() : 0); } } else if (imageDisplay.getRolloverUrl() != null) { if (imageDisplay.getRolloverUrl().startsWith(MediaURLStreamHandler.MEDIA_URL_DEF)) { String mediaName = imageDisplay.getRolloverUrl() .substring(MediaURLStreamHandler.MEDIA_URL_DEF.length()); if (mediaName.startsWith(MediaURLStreamHandler.MEDIA_URL_BLOBLOADER)) { ICrypt urlCrypt = null; if (Application.exists()) urlCrypt = Application.get().getSecuritySettings().getCryptFactory().newCrypt(); url = StripHTMLTagsConverter.generateBlobloaderUrl(imageDisplayComponent, urlCrypt, mediaName); } } else url = imageDisplay.getRolloverUrl(); } return "Servoy.Rollover.onMouseOver('" + imageDisplayComponent.getMarkupId() + "_img','" + url //$NON-NLS-1$//$NON-NLS-2$ + "')"; //$NON-NLS-1$ } }) { @Override protected String newValue(final String currentValue, final String replacementValue) { return replacementValue + ";" + currentValue; } }; } return null; }
From source file:org.devproof.portal.core.module.common.component.ValidationDisplayBehaviour.java
License:Apache License
private void printErrorMessage(CharSequence msg, Component componentWithError) { PackagedTextTemplate template = new PackagedTextTemplate(ValidationDisplayBehaviour.class, "ValidationDisplayBehaviour.html"); Map<String, Object> variables = new MiniMap<String, Object>(4); variables.put("message", msg); variables.put("imageUrl", componentWithError.urlFor(ERRORHINT_IMAGE_REF)); variables.put("imageId", componentWithError.getMarkupId() + "Image"); variables.put("popupId", componentWithError.getMarkupId() + "Popup"); componentWithError.getResponse().write(template.asString(variables)); }
From source file:org.wicketstuff.dojo11.skin.AbstractDojoSkin.java
License:Apache License
/** * Get the css to used for the widget is this file exist otherwise return * null// w ww . j a v a2 s .c o m * * @param component * Component to skin * @param behavior * Dojo component behavior * @return the css to used for the widget is this file exist otherwise * return null */ public final String getTemplateCssPath(Component component, AbstractRequireDojoBehavior behavior) { String cssTemplate = getClassName(behavior.getClass().getName()).replaceAll("Handler", "") + ".css"; if (exists(cssTemplate)) { return (String) component.urlFor(new ResourceReference(getResourceClass(), cssTemplate)); } else { return null; } }
From source file:org.wicketstuff.dojo11.skin.AbstractDojoSkin.java
License:Apache License
/** * Get the htm to used for the widget is this file exist otherwise return * null/*from w ww .j a va2 s . co m*/ * * @param component * Component to skin * @param behavior * Dojo component behavior * @return the htm to used for the widget is this file exist otherwise * return null */ public final String getTemplateHtmlPath(Component component, AbstractRequireDojoBehavior behavior) { String htmlTemplate = getClassName(behavior.getClass().getName().replaceAll("Handler", "")) + ".htm"; if (exists(htmlTemplate)) { return (String) component.urlFor(new ResourceReference(getResourceClass(), htmlTemplate)); } else { return null; } }