Author: pgolawski
Date: 2008-08-04 04:51:37 -0400 (Mon, 04 Aug 2008)
New Revision: 9875
Modified:
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/RichTableMenuRenderer.java
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/SimpleTableMenuRenderer.java
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/TableMenuRenderer.java
Log:
used InternetResource
Modified:
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/RichTableMenuRenderer.java
===================================================================
---
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/RichTableMenuRenderer.java 2008-08-04
08:21:47 UTC (rev 9874)
+++
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/RichTableMenuRenderer.java 2008-08-04
08:51:37 UTC (rev 9875)
@@ -8,10 +8,10 @@
import javax.faces.component.UIComponent;
-import org.ajax4jsf.Messages;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.resource.InternetResource;
import org.richfaces.component.UIColumn;
import org.richfaces.component.UIContextMenu;
import org.richfaces.component.UIMenuGroup;
@@ -48,62 +48,19 @@
/*
* Icon URIs
*/
- private static String iconColumnsURI;
- private static String iconSortAscURI;
- private static String iconSortDescURI;
- private static String iconGroupURI;
- private static String iconCheckedURI;
- private static String iconUncheckedURI;
+ private static String iconColumnsURI = InternetResource.RESOURCE_URI_PREFIX +
"/org/richfaces/renderkit/html/images/columns.png";
+ private static String iconSortAscURI = InternetResource.RESOURCE_URI_PREFIX +
"/org/richfaces/renderkit/html/images/menu-sort-asc.png";
+ private static String iconSortDescURI = InternetResource.RESOURCE_URI_PREFIX +
"/org/richfaces/renderkit/html/images/menu-sort-desc.png";
+ private static String iconGroupURI = InternetResource.RESOURCE_URI_PREFIX +
"/org/richfaces/renderkit/html/images/group-by.png";
+ private static String iconCheckedURI = InternetResource.RESOURCE_URI_PREFIX +
"/org/richfaces/renderkit/html/images/checked.gif";
+ private static String iconUncheckedURI = InternetResource.RESOURCE_URI_PREFIX +
"/org/richfaces/renderkit/html/images/unchecked.gif";
- /**
- * Initializes resources if they are not initialized yet. Each icon URI is
- * kept in class field to ensure that resource URI is build only once.
- */
- private void initResources() {
- if (context == null) {
- throw new NullPointerException(Messages.getMessage(
- Messages.CONTEXT_NULL_ERROR, "initResources"));
- }
-
- if (iconColumnsURI == null) {
- iconColumnsURI = getUri(
-
getResource("/org/richfaces/renderkit/html/images/columns.png"),
- context);
- }
- if (iconSortAscURI == null) {
- iconSortAscURI = getUri(
-
getResource("/org/richfaces/renderkit/html/images/menu-sort-asc.png"),
- context);
- }
- if (iconSortDescURI == null) {
- iconSortDescURI = getUri(
-
getResource("/org/richfaces/renderkit/html/images/menu-sort-desc.png"),
- context);
- }
- if (iconGroupURI == null) {
- iconGroupURI = getUri(
-
getResource("/org/richfaces/renderkit/html/images/group-by.png"),
- context);
- }
- if (iconCheckedURI == null) {
- iconCheckedURI = getUri(
-
getResource("/org/richfaces/renderkit/html/images/checked.gif"),
- context);
- }
- if (iconUncheckedURI == null) {
- iconUncheckedURI = getUri(
-
getResource("/org/richfaces/renderkit/html/images/unchecked.gif"),
- context);
- }
- }// initResources
-
/*
* (non-Javadoc)
*
* @see org.richfaces.renderkit.html.TableMenuRenderer#render()
*/
public String render() throws IOException {
- initResources();
ensureMenuBuilt();
String menuId = menu.getClientId(context);
// render menu
Modified:
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/SimpleTableMenuRenderer.java
===================================================================
---
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/SimpleTableMenuRenderer.java 2008-08-04
08:21:47 UTC (rev 9874)
+++
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/SimpleTableMenuRenderer.java 2008-08-04
08:51:37 UTC (rev 9875)
@@ -15,6 +15,8 @@
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
import org.richfaces.component.UIColumn;
/**
@@ -115,9 +117,9 @@
writer.startElement(HTML.IMG_ELEMENT, dataColumn);
writer.writeAttribute(HTML.class_ATTRIBUTE, "dt-menu-item-icon",
null);
- writer.writeAttribute(HTML.src_ATTRIBUTE, getResource(
- "/org/richfaces/renderkit/html/images/s.gif").getUri(
- context, null), null);
+ InternetResource res =
InternetResourceBuilder.getInstance().getResource("/org/richfaces/renderkit/html/images/s.gif");
+ writer.writeAttribute(HTML.src_ATTRIBUTE, InternetResourceBuilder
+ .getInstance().getUri(res, context, null), null);
writer.endElement(HTML.IMG_ELEMENT);
String label = (String)dataColumn.getAttributes().get("label");
writer.writeText(label == null ? "" : label, null);
Modified:
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/TableMenuRenderer.java
===================================================================
---
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/TableMenuRenderer.java 2008-08-04
08:21:47 UTC (rev 9874)
+++
trunk/sandbox/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/html/TableMenuRenderer.java 2008-08-04
08:51:37 UTC (rev 9875)
@@ -6,15 +6,11 @@
import java.io.IOException;
import java.io.Serializable;
-import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceNotFoundException;
-import org.ajax4jsf.webapp.WebXml;
import org.richfaces.component.UIColumn;
import org.richfaces.component.UIExtendedDataTable;
@@ -77,53 +73,6 @@
public abstract JSFunctionDefinition createShowMenuEventFunction();
/**
- * Base stub method for produce Internet resource ( image, script ... )
- * since resources must be implemented in "lightweight" pattern, it
- * instances put in internal map to caching.
- *
- * @param resourceURI -
- * relative ( to renderer class ) URI to resource in jar or key
- * for generate ( in Java2D , for example ).
- * @return - resource instance for this URI.
- * @throws ResourceNotFoundException -
- * if requested resource not instantiated.
- */
- public InternetResource getResource(String resourceURI)
- throws FacesException {
- return getResourceBuilder().createResource(null, resourceURI);
- }
-
- protected static InternetResourceBuilder getResourceBuilder() {
- if (resourceBuilder == null) {
- resourceBuilder = InternetResourceBuilder.getInstance();
- }
- return resourceBuilder;
- }
-
- protected String getUri(InternetResource resource, FacesContext context) {
- return getFacesResourceURL(context, resource.getKey());
- }// getUri
-
- protected String getFacesResourceURL(FacesContext context, String Url) {
- WebXml webXml = WebXml.getInstance(context);
- StringBuffer buf = new StringBuffer();
- //TODO nick - use InternetResourceBuilder
- buf.append(webXml.getResourcePrefix()).append(Url);
- // Insert suffix mapping
- if (webXml.isPrefixMapping()) {
- buf.insert(0, webXml.getFacesFilterPrefix());
- } else {
- int index;
- if ((index = buf.indexOf("?")) >= 0) {
- buf.insert(index, webXml.getFacesFilterSuffix());
- } else {
- buf.append(webXml.getFacesFilterSuffix());
- }
- }
- return buf.toString();
- }// getFacesResourceURL
-
- /**
* Sets function to be called on complete AJAX request fired by menu action
*
* @param functionDefinition