You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/07/03 23:58:25 UTC
svn commit: r673833 [10/18] - in /myfaces/tomahawk/trunk:
core/src/main/java/org/apache/myfaces/component/
core/src/main/java/org/apache/myfaces/component/html/ext/
core/src/main/java/org/apache/myfaces/component/html/util/
core/src/main/java/org/apach...
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fieldset/FieldsetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fieldset/FieldsetRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fieldset/FieldsetRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fieldset/FieldsetRenderer.java Thu Jul 3 14:58:05 2008
@@ -43,7 +43,7 @@
public boolean getRendersChildren()
{
- return true;
+ return true;
}
public void encodeBegin(FacesContext context, UIComponent component)
@@ -54,11 +54,11 @@
if (fieldset.isRendered())
{
- super.encodeBegin(context, component);
- String legend = fieldset.getLegend();
- if( legend == null || legend.trim().length() == 0 ) // Don't render the legend
- return;
-
+ super.encodeBegin(context, component);
+ String legend = fieldset.getLegend();
+ if( legend == null || legend.trim().length() == 0 ) // Don't render the legend
+ return;
+
ResponseWriter writer = context.getResponseWriter();
writer.startElement("legend", fieldset);
@@ -68,7 +68,7 @@
}
public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
- RendererUtils.renderChildren(context, component);
+ RendererUtils.renderChildren(context, component);
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenuRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenuRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenuRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/fisheye/HtmlFishEyeNavigationMenuRenderer.java Thu Jul 3 14:58:05 2008
@@ -157,11 +157,11 @@
if (fisheye.getVisibleWindow() != null) {
paramMap.put("visibleWindow", fisheye.getVisibleWindow());
} else {
- HtmlFishEyeNavigationMenu menu = (HtmlFishEyeNavigationMenu) component;
- int visibleWindow = calculateVisbleWindow(component, menu);
+ HtmlFishEyeNavigationMenu menu = (HtmlFishEyeNavigationMenu) component;
+ int visibleWindow = calculateVisbleWindow(component, menu);
paramMap.put("visibleWindow",new Integer( visibleWindow)); //lets expand, the fisheye will shrink it as needed
}
-
+
paramMap.put(ITEM_WIDTH_ATTR, fisheye.getItemWidth());
paramMap.put(ITEM_HEIGHT_ATTR, fisheye.getItemHeight());
@@ -191,24 +191,24 @@
}
- private int calculateVisbleWindow(UIComponent component, HtmlFishEyeNavigationMenu menu) {
- int visibleWindow = 0;
- if (menu.getChildCount() == 1 && menu.getChildren().get(0) instanceof FishEyeCommandLink) {
- visibleWindow = menu.getRowCount();
- } else {
- List children = component.getChildren();
-
- for (Iterator cit = children.iterator(); cit.hasNext();) {
- UIComponent child = (UIComponent) cit.next();
- if (!child.isRendered())
- continue;
- if (child instanceof UINavigationMenuItem) {
- visibleWindow += 1;
- }
- }
- }
- return visibleWindow;
- }
+ private int calculateVisbleWindow(UIComponent component, HtmlFishEyeNavigationMenu menu) {
+ int visibleWindow = 0;
+ if (menu.getChildCount() == 1 && menu.getChildren().get(0) instanceof FishEyeCommandLink) {
+ visibleWindow = menu.getRowCount();
+ } else {
+ List children = component.getChildren();
+
+ for (Iterator cit = children.iterator(); cit.hasNext();) {
+ UIComponent child = (UIComponent) cit.next();
+ if (!child.isRendered())
+ continue;
+ if (child instanceof UINavigationMenuItem) {
+ visibleWindow += 1;
+ }
+ }
+ }
+ return visibleWindow;
+ }
private Stack getChildsMenuStack(FacesContext context, UIComponent component) {
Stack menuStack = (Stack) ((HttpServletRequest) context.getExternalContext().getRequest()).getAttribute(component.getClientId(context)
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/focus/AbstractHtmlFocus.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/focus/AbstractHtmlFocus.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/focus/AbstractHtmlFocus.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/focus/AbstractHtmlFocus.java Thu Jul 3 14:58:05 2008
@@ -43,12 +43,12 @@
private static Log log = LogFactory.getLog(AbstractHtmlFocus.class);
- /**
- * The JSF id of the component to receive focus.
- *
- * @JSFProperty
- */
- public abstract String getFor();
+ /**
+ * The JSF id of the component to receive focus.
+ *
+ * @JSFProperty
+ */
+ public abstract String getFor();
/**
* @JSFProperty
@@ -58,21 +58,21 @@
protected UIComponent findUIComponent()
- {
- String forStr = getFor();
+ {
+ String forStr = getFor();
- if (forStr == null)
- {
- throw new IllegalArgumentException("focus@for must be specified");
- }
-
- UIComponent forComp = findComponent(forStr);
- if (forComp == null)
- {
- log.warn("could not find UIComponent referenced by attribute focus@for = '"
- + forStr + "'");
- }
- return forComp;
- }
+ if (forStr == null)
+ {
+ throw new IllegalArgumentException("focus@for must be specified");
+ }
+
+ UIComponent forComp = findComponent(forStr);
+ if (forComp == null)
+ {
+ log.warn("could not find UIComponent referenced by attribute focus@for = '"
+ + forStr + "'");
+ }
+ return forComp;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/focus/HtmlFocusRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/focus/HtmlFocusRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/focus/HtmlFocusRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/focus/HtmlFocusRenderer.java Thu Jul 3 14:58:05 2008
@@ -70,14 +70,14 @@
if(targetComponent != null)
{
- if (focus.isRememberClientFocus())
- {
- String javascriptLocation = (String)uiComponent.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
- DojoUtils.addMainInclude(facesContext, uiComponent, javascriptLocation, new DojoConfig());
- DojoUtils.addRequire(facesContext, uiComponent, "dojo.event.*");
- }
+ if (focus.isRememberClientFocus())
+ {
+ String javascriptLocation = (String)uiComponent.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
+ DojoUtils.addMainInclude(facesContext, uiComponent, javascriptLocation, new DojoConfig());
+ DojoUtils.addRequire(facesContext, uiComponent, "dojo.event.*");
+ }
- String clientId = targetComponent.getClientId(facesContext);
+ String clientId = targetComponent.getClientId(facesContext);
if(targetComponent instanceof HtmlInputDate)
{
clientId = HtmlDateRenderer.getClientIdForDaySubcomponent(clientId);
@@ -89,15 +89,15 @@
writer.writeText("setTimeout(\"document.getElementById('" + clientId + "').focus()\", 100)", null);
writer.endElement(HTML.SCRIPT_ELEM);
- if (focus.isRememberClientFocus())
- {
- writer.startElement(HTML.INPUT_ELEM, uiComponent);
- writer.writeAttribute(HTML.TYPE_ATTR,HTML.INPUT_TYPE_HIDDEN,null);
- writer.writeAttribute(HTML.ID_ATTR,uiComponent.getClientId(facesContext), JSFAttr.ID_ATTR);
- writer.writeAttribute(HTML.VALUE_ATTR,clientId,JSFAttr.VALUE_ATTR);
- writer.endElement(HTML.INPUT_ELEM);
- }
- }
+ if (focus.isRememberClientFocus())
+ {
+ writer.startElement(HTML.INPUT_ELEM, uiComponent);
+ writer.writeAttribute(HTML.TYPE_ATTR,HTML.INPUT_TYPE_HIDDEN,null);
+ writer.writeAttribute(HTML.ID_ATTR,uiComponent.getClientId(facesContext), JSFAttr.ID_ATTR);
+ writer.writeAttribute(HTML.VALUE_ATTR,clientId,JSFAttr.VALUE_ATTR);
+ writer.endElement(HTML.INPUT_ELEM);
+ }
+ }
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/form/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/form/HtmlFormRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/form/HtmlFormRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/form/HtmlFormRenderer.java Thu Jul 3 14:58:05 2008
@@ -41,8 +41,8 @@
*/
public class HtmlFormRenderer extends HtmlFormRendererBase
{
- private static String CLIENT_VALIDATON_SCRIPT = "return tomahawk.executeClientLifeCycle();";
-
+ private static String CLIENT_VALIDATON_SCRIPT = "return tomahawk.executeClientLifeCycle();";
+
/**
* @see org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlFormRendererBase#getActionUrl(javax.faces.context.FacesContext, javax.faces.component.UIForm )
*/
@@ -133,37 +133,37 @@
}
public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
- if(CVUtils.isCVEnabled()) {
- if(!isDecorated(facesContext, component))
- decorateOnSubmit(facesContext, component);
- }
- super.encodeBegin(facesContext, component);
+ if(CVUtils.isCVEnabled()) {
+ if(!isDecorated(facesContext, component))
+ decorateOnSubmit(facesContext, component);
+ }
+ super.encodeBegin(facesContext, component);
}
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
- super.encodeEnd(facesContext, component);
- if(CVUtils.isCVEnabled()) {
- CVUtils.encodeJavascript(facesContext);
- CVUtils.queueCVCalls(facesContext.getViewRoot());
- CVUtils.encodeValidationScript(facesContext);
- }
+ super.encodeEnd(facesContext, component);
+ if(CVUtils.isCVEnabled()) {
+ CVUtils.encodeJavascript(facesContext);
+ CVUtils.queueCVCalls(facesContext.getViewRoot());
+ CVUtils.encodeValidationScript(facesContext);
+ }
}
private boolean isDecorated(FacesContext facesContext, UIComponent child) {
- String onSubmit= (String) child.getAttributes().get("onsubmit");
-
- if(onSubmit == null || onSubmit.indexOf(CLIENT_VALIDATON_SCRIPT) == -1)
- return false;
- else
- return true;
- }
-
- private void decorateOnSubmit(FacesContext facesContext, UIComponent child) {
- String onSubmitEvent = (String) child.getAttributes().get("onsubmit");
- if(onSubmitEvent == null)
- child.getAttributes().put("onsubmit", CLIENT_VALIDATON_SCRIPT);
- else
- child.getAttributes().put("onsubmit", onSubmitEvent + ";" + CLIENT_VALIDATON_SCRIPT);
- }
+ String onSubmit= (String) child.getAttributes().get("onsubmit");
+
+ if(onSubmit == null || onSubmit.indexOf(CLIENT_VALIDATON_SCRIPT) == -1)
+ return false;
+ else
+ return true;
+ }
+
+ private void decorateOnSubmit(FacesContext facesContext, UIComponent child) {
+ String onSubmitEvent = (String) child.getAttributes().get("onsubmit");
+ if(onSubmitEvent == null)
+ child.getAttributes().put("onsubmit", CLIENT_VALIDATON_SCRIPT);
+ else
+ child.getAttributes().put("onsubmit", onSubmitEvent + ";" + CLIENT_VALIDATON_SCRIPT);
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/GraphicImageDynamic.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/GraphicImageDynamic.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/GraphicImageDynamic.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/GraphicImageDynamic.java Thu Jul 3 14:58:05 2008
@@ -65,10 +65,10 @@
public static final String COMPONENT_TYPE = "org.apache.myfaces.GraphicImageDynamic";
public static final String COMPONENT_FAMILY = "javax.faces.Graphic";
public static final String RENDERER_PARAM = "_renderer";
- public static final String VALUE_PARAM = "_value";
- public static final String WIDTH_PARAM = "_width";
- public static final String HEIGHT_PARAM = "_height";
- private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.GraphicImageDynamicRenderer";
+ public static final String VALUE_PARAM = "_value";
+ public static final String WIDTH_PARAM = "_width";
+ public static final String HEIGHT_PARAM = "_height";
+ private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.GraphicImageDynamicRenderer";
public GraphicImageDynamic()
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/GraphicImageDynamicRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/GraphicImageDynamicRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/GraphicImageDynamicRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/GraphicImageDynamicRenderer.java Thu Jul 3 14:58:05 2008
@@ -63,126 +63,126 @@
* @author Sylvain Vieujot
*/
public class GraphicImageDynamicRenderer extends HtmlImageRenderer implements
- ResourceLoader {
-
- private static final Log log = LogFactory
- .getLog(GraphicImageDynamicRenderer.class);
+ ResourceLoader {
+
+ private static final Log log = LogFactory
+ .getLog(GraphicImageDynamicRenderer.class);
public static final String RENDERER_TYPE = "org.apache.myfaces.GraphicImageDynamicRenderer";
public void encodeEnd(FacesContext context, UIComponent component)
- throws IOException {
+ throws IOException {
- GraphicImageDynamic graphicImageDynamic = (GraphicImageDynamic) component;
- String width = graphicImageDynamic.getWidth();
- String height = graphicImageDynamic.getHeight();
- ResponseWriter writer = context.getResponseWriter();
- Map params = ComponentUtils.getParameterMap(component);
- Class imageRendererClass = graphicImageDynamic.getImageRendererClass();
- ValueBinding imageRendererValueBinding = graphicImageDynamic
- .getValueBinding("value");
- AddResource addResource;
- String url;
-
- // render the img HTML element.
- RendererUtils.checkParamValidity(context, component,
- GraphicImageDynamic.class);
-
- writer.startElement(HTML.IMG_ELEM, graphicImageDynamic);
-
- HtmlRendererUtils.writeIdIfNecessary(writer, graphicImageDynamic,
- context);
- HtmlRendererUtils.renderHTMLAttributes(writer, graphicImageDynamic,
- HTML.IMG_PASSTHROUGH_ATTRIBUTES);
-
- if (width != null) {
- params.put(GraphicImageDynamic.WIDTH_PARAM, width);
- }
-
- if (height != null) {
- params.put(GraphicImageDynamic.HEIGHT_PARAM, height);
- }
-
- if (imageRendererClass != null) {
- params.put(GraphicImageDynamic.RENDERER_PARAM, imageRendererClass
- .getName());
- }
-
- if (imageRendererValueBinding != null) {
- params.put(GraphicImageDynamic.VALUE_PARAM,
- imageRendererValueBinding.getExpressionString());
- }
-
- addResource = AddResourceFactory.getInstance(context);
- url = context.getExternalContext().encodeResourceURL(
- addResource.getResourceUri(context,
- new ParameterResourceHandler(this.getClass(), params)));
- writer.writeAttribute(HTML.SRC_ATTR, url, null);
+ GraphicImageDynamic graphicImageDynamic = (GraphicImageDynamic) component;
+ String width = graphicImageDynamic.getWidth();
+ String height = graphicImageDynamic.getHeight();
+ ResponseWriter writer = context.getResponseWriter();
+ Map params = ComponentUtils.getParameterMap(component);
+ Class imageRendererClass = graphicImageDynamic.getImageRendererClass();
+ ValueBinding imageRendererValueBinding = graphicImageDynamic
+ .getValueBinding("value");
+ AddResource addResource;
+ String url;
+
+ // render the img HTML element.
+ RendererUtils.checkParamValidity(context, component,
+ GraphicImageDynamic.class);
+
+ writer.startElement(HTML.IMG_ELEM, graphicImageDynamic);
+
+ HtmlRendererUtils.writeIdIfNecessary(writer, graphicImageDynamic,
+ context);
+ HtmlRendererUtils.renderHTMLAttributes(writer, graphicImageDynamic,
+ HTML.IMG_PASSTHROUGH_ATTRIBUTES);
+
+ if (width != null) {
+ params.put(GraphicImageDynamic.WIDTH_PARAM, width);
+ }
+
+ if (height != null) {
+ params.put(GraphicImageDynamic.HEIGHT_PARAM, height);
+ }
+
+ if (imageRendererClass != null) {
+ params.put(GraphicImageDynamic.RENDERER_PARAM, imageRendererClass
+ .getName());
+ }
+
+ if (imageRendererValueBinding != null) {
+ params.put(GraphicImageDynamic.VALUE_PARAM,
+ imageRendererValueBinding.getExpressionString());
+ }
+
+ addResource = AddResourceFactory.getInstance(context);
+ url = context.getExternalContext().encodeResourceURL(
+ addResource.getResourceUri(context,
+ new ParameterResourceHandler(this.getClass(), params)));
+ writer.writeAttribute(HTML.SRC_ATTR, url, null);
- writer.endElement(HTML.IMG_ELEM);
- }
+ writer.endElement(HTML.IMG_ELEM);
+ }
public void decode(FacesContext facesContext, UIComponent component) {
- super.decode(facesContext, component);
- }
+ super.decode(facesContext, component);
+ }
public void serveResource(ServletContext servletContext,
- HttpServletRequest request, HttpServletResponse response,
- String resourceUri) throws IOException {
+ HttpServletRequest request, HttpServletResponse response,
+ String resourceUri) throws IOException {
- // get the facesContext from the servletContext.
- FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder
- .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
- .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
- Lifecycle lifecycle = lifecycleFactory.getLifecycle(ComponentUtils
- .getLifecycleId(servletContext));
- FacesContext facesContext = facesContextFactory.getFacesContext(
- servletContext, request, response, lifecycle);
-
- facesContext.setResponseStream(new ImageResponseStream(response
- .getOutputStream()));
-
- // render the image.
- try {
-
- ImageRenderer imageRenderer = null;
- Map requestMap = facesContext.getExternalContext()
- .getRequestParameterMap();
- Object rendererValue = requestMap
- .get(GraphicImageDynamic.RENDERER_PARAM);
-
- if (rendererValue != null) {
- imageRenderer = GraphicsImageDynamicHelper
- .getImageRendererFromClassName(rendererValue.toString());
- } else {
- Object rendererValueBinding = requestMap
- .get(GraphicImageDynamic.VALUE_PARAM);
-
- if (rendererValueBinding != null) {
- imageRenderer = GraphicsImageDynamicHelper
- .getImageRendererFromValueBinding(facesContext,
- rendererValueBinding.toString());
- }
- }
-
- if (imageRenderer == null) {
- throw new FacesException(
- GraphicImageDynamicConstants.NO_IMAGE_RENDERER_DEFINED);
- }
-
- try {
- renderImage(imageRenderer, facesContext);
- } catch (Exception e) {
- throw new FacesException(
- GraphicImageDynamicConstants.MSG_COULDNOT_RENDER_IMAGE
- + rendererValue + " : " + e.getMessage(), e);
- }
-
- facesContext.getResponseStream().close();
- } finally {
- facesContext.release();
- }
- }
+ // get the facesContext from the servletContext.
+ FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder
+ .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+ LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
+ .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ Lifecycle lifecycle = lifecycleFactory.getLifecycle(ComponentUtils
+ .getLifecycleId(servletContext));
+ FacesContext facesContext = facesContextFactory.getFacesContext(
+ servletContext, request, response, lifecycle);
+
+ facesContext.setResponseStream(new ImageResponseStream(response
+ .getOutputStream()));
+
+ // render the image.
+ try {
+
+ ImageRenderer imageRenderer = null;
+ Map requestMap = facesContext.getExternalContext()
+ .getRequestParameterMap();
+ Object rendererValue = requestMap
+ .get(GraphicImageDynamic.RENDERER_PARAM);
+
+ if (rendererValue != null) {
+ imageRenderer = GraphicsImageDynamicHelper
+ .getImageRendererFromClassName(rendererValue.toString());
+ } else {
+ Object rendererValueBinding = requestMap
+ .get(GraphicImageDynamic.VALUE_PARAM);
+
+ if (rendererValueBinding != null) {
+ imageRenderer = GraphicsImageDynamicHelper
+ .getImageRendererFromValueBinding(facesContext,
+ rendererValueBinding.toString());
+ }
+ }
+
+ if (imageRenderer == null) {
+ throw new FacesException(
+ GraphicImageDynamicConstants.NO_IMAGE_RENDERER_DEFINED);
+ }
+
+ try {
+ renderImage(imageRenderer, facesContext);
+ } catch (Exception e) {
+ throw new FacesException(
+ GraphicImageDynamicConstants.MSG_COULDNOT_RENDER_IMAGE
+ + rendererValue + " : " + e.getMessage(), e);
+ }
+
+ facesContext.getResponseStream().close();
+ } finally {
+ facesContext.release();
+ }
+ }
/**
* This method is used for rendering the image.
@@ -190,31 +190,31 @@
* @param facesContext
* @throws Exception
*/
- protected void renderImage(ImageRenderer imageRenderer,
- FacesContext facesContext) throws Exception {
+ protected void renderImage(ImageRenderer imageRenderer,
+ FacesContext facesContext) throws Exception {
- ImageContext imageContext = GraphicsImageDynamicHelper
- .createImageContext(facesContext, log);
- imageRenderer.setContext(facesContext, imageContext);
- HttpServletResponse response = (HttpServletResponse) facesContext
- .getExternalContext().getResponse();
- int contentLength = imageRenderer.getContentLength();
- String contentType = imageRenderer.getContentType();
- ResponseStream out = facesContext.getResponseStream();
-
- if (contentLength > 0) {
- response.setContentLength(contentLength);
- }
-
- if (contentType != null && contentType.length() > 0) {
- response.setContentType(contentType);
- }
-
- try {
- imageRenderer.renderResource(out);
- } finally {
- out.close();
- facesContext.responseComplete();
- }
- }
+ ImageContext imageContext = GraphicsImageDynamicHelper
+ .createImageContext(facesContext, log);
+ imageRenderer.setContext(facesContext, imageContext);
+ HttpServletResponse response = (HttpServletResponse) facesContext
+ .getExternalContext().getResponse();
+ int contentLength = imageRenderer.getContentLength();
+ String contentType = imageRenderer.getContentType();
+ ResponseStream out = facesContext.getResponseStream();
+
+ if (contentLength > 0) {
+ response.setContentLength(contentLength);
+ }
+
+ if (contentType != null && contentType.length() > 0) {
+ response.setContentType(contentType);
+ }
+
+ try {
+ imageRenderer.renderResource(out);
+ } finally {
+ out.close();
+ facesContext.responseComplete();
+ }
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/ImageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/ImageRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/ImageRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/ImageRenderer.java Thu Jul 3 14:58:05 2008
@@ -29,14 +29,14 @@
*/
public interface ImageRenderer extends ResourceRenderer
{
- /**
- * This method will be called first, to set the contexts.
- *
+ /**
+ * This method will be called first, to set the contexts.
+ *
* @param facesContext the faces context
* @param imageContext the image context width aditional image parameters
- *
- void setContext(FacesContext facesContext, ImageContext imageContext) throws Exception;
- */
+ *
+ void setContext(FacesContext facesContext, ImageContext imageContext) throws Exception;
+ */
/**
* Called to render the image to the given outputstream.
*
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/GraphicImageDynamicConstants.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/GraphicImageDynamicConstants.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/GraphicImageDynamicConstants.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/GraphicImageDynamicConstants.java Thu Jul 3 14:58:05 2008
@@ -20,6 +20,6 @@
package org.apache.myfaces.custom.graphicimagedynamic.util;
public interface GraphicImageDynamicConstants {
- String NO_IMAGE_RENDERER_DEFINED = "no image renderer defined.";
- String MSG_COULDNOT_RENDER_IMAGE = "could not render image ";
+ String NO_IMAGE_RENDERER_DEFINED = "no image renderer defined.";
+ String MSG_COULDNOT_RENDER_IMAGE = "could not render image ";
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/GraphicsImageDynamicHelper.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/GraphicsImageDynamicHelper.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/GraphicsImageDynamicHelper.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/GraphicsImageDynamicHelper.java Thu Jul 3 14:58:05 2008
@@ -34,91 +34,91 @@
* GraphicsImageDynamic component.
*/
public class GraphicsImageDynamicHelper {
-
- /**
- * This method is used for getting the ImageRenderer
- * from the image render class.
- * @param imageRendererClassName
- * @return the image renderer
- */
- public static ImageRenderer getImageRendererFromClassName(
- String imageRendererClassName) {
- ImageRenderer imageRenderer;
- try {
- Class rendererClass = ClassUtils
- .classForName(imageRendererClassName);
- if (!ImageRenderer.class.isAssignableFrom(rendererClass)) {
- throw new FacesException("Image renderer class ["
- + imageRendererClassName + "] does not implement "
- + ImageRenderer.class.getName());
- }
- try {
- imageRenderer = (ImageRenderer) rendererClass.newInstance();
- } catch (InstantiationException e) {
- throw new FacesException(
- "could not instantiate image renderer class "
- + imageRendererClassName + " : "
- + e.getMessage(), e);
- } catch (IllegalAccessException e) {
- throw new FacesException(
- "could not instantiate image renderer class "
- + imageRendererClassName + " : "
- + e.getMessage(), e);
- }
- } catch (ClassNotFoundException e) {
- throw new FacesException("image renderer class not found: "
- + e.getMessage(), e);
- }
- return imageRenderer;
- }
+
+ /**
+ * This method is used for getting the ImageRenderer
+ * from the image render class.
+ * @param imageRendererClassName
+ * @return the image renderer
+ */
+ public static ImageRenderer getImageRendererFromClassName(
+ String imageRendererClassName) {
+ ImageRenderer imageRenderer;
+ try {
+ Class rendererClass = ClassUtils
+ .classForName(imageRendererClassName);
+ if (!ImageRenderer.class.isAssignableFrom(rendererClass)) {
+ throw new FacesException("Image renderer class ["
+ + imageRendererClassName + "] does not implement "
+ + ImageRenderer.class.getName());
+ }
+ try {
+ imageRenderer = (ImageRenderer) rendererClass.newInstance();
+ } catch (InstantiationException e) {
+ throw new FacesException(
+ "could not instantiate image renderer class "
+ + imageRendererClassName + " : "
+ + e.getMessage(), e);
+ } catch (IllegalAccessException e) {
+ throw new FacesException(
+ "could not instantiate image renderer class "
+ + imageRendererClassName + " : "
+ + e.getMessage(), e);
+ }
+ } catch (ClassNotFoundException e) {
+ throw new FacesException("image renderer class not found: "
+ + e.getMessage(), e);
+ }
+ return imageRenderer;
+ }
- /**
- * This method gets the image renderer from the ValueBinding.
- * @param facesContext
- * @param rendererValueBinding
- * @return the ImageRenderer.
- */
- public static ImageRenderer getImageRendererFromValueBinding(
- FacesContext facesContext, String rendererValueBinding) {
- return (ImageRenderer) facesContext.getApplication()
- .createValueBinding(rendererValueBinding).getValue(
- facesContext);
- }
-
-
- /**
- * This method is used for creating the image context.
- * @param facesContext
- * @return the imageContext.
- */
+ /**
+ * This method gets the image renderer from the ValueBinding.
+ * @param facesContext
+ * @param rendererValueBinding
+ * @return the ImageRenderer.
+ */
+ public static ImageRenderer getImageRendererFromValueBinding(
+ FacesContext facesContext, String rendererValueBinding) {
+ return (ImageRenderer) facesContext.getApplication()
+ .createValueBinding(rendererValueBinding).getValue(
+ facesContext);
+ }
+
+
+ /**
+ * This method is used for creating the image context.
+ * @param facesContext
+ * @return the imageContext.
+ */
public static ImageContext createImageContext(FacesContext facesContext,
- Log log) {
+ Log log) {
- ExternalContext externalContext = facesContext.getExternalContext();
- final Map requestMap = externalContext.getRequestParameterMap();
- Object value = requestMap.get(GraphicImageDynamic.WIDTH_PARAM);
- Integer height = null;
- Integer width = null;
+ ExternalContext externalContext = facesContext.getExternalContext();
+ final Map requestMap = externalContext.getRequestParameterMap();
+ Object value = requestMap.get(GraphicImageDynamic.WIDTH_PARAM);
+ Integer height = null;
+ Integer width = null;
- if (value != null) {
- try {
- width = Integer.valueOf(value.toString());
- } catch (NumberFormatException e) {
- log.error("Invalid value for image width : " + value + ", "
- + e.getMessage(), e);
- }
- }
+ if (value != null) {
+ try {
+ width = Integer.valueOf(value.toString());
+ } catch (NumberFormatException e) {
+ log.error("Invalid value for image width : " + value + ", "
+ + e.getMessage(), e);
+ }
+ }
- value = requestMap.get(GraphicImageDynamic.HEIGHT_PARAM);
- if (value != null) {
- try {
- height = Integer.valueOf(value.toString());
- } catch (NumberFormatException e) {
- log.error("Invalid value for image height : " + value + ", "
- + e.getMessage(), e);
- }
- }
+ value = requestMap.get(GraphicImageDynamic.HEIGHT_PARAM);
+ if (value != null) {
+ try {
+ height = Integer.valueOf(value.toString());
+ } catch (NumberFormatException e) {
+ log.error("Invalid value for image height : " + value + ", "
+ + e.getMessage(), e);
+ }
+ }
- return new SimpleImageContext(requestMap, width, height);
- }
+ return new SimpleImageContext(requestMap, width, height);
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/ImageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/ImageRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/ImageRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/ImageRenderer.java Thu Jul 3 14:58:05 2008
@@ -30,14 +30,14 @@
*/
public interface ImageRenderer extends ResourceRenderer
{
- /**
- * This method will be called first, to set the contexts.
- *
+ /**
+ * This method will be called first, to set the contexts.
+ *
* @param facesContext the faces context
* @param imageContext the image context width aditional image parameters
- *
- void setContext(FacesContext facesContext, ImageContext imageContext) throws Exception;
- */
+ *
+ void setContext(FacesContext facesContext, ImageContext imageContext) throws Exception;
+ */
/**
* Called to render the image to the given outputstream.
*
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/ImageResponseStream.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/ImageResponseStream.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/ImageResponseStream.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/ImageResponseStream.java Thu Jul 3 14:58:05 2008
@@ -29,30 +29,30 @@
*/
public class ImageResponseStream extends ResponseStream {
- private final OutputStream _out;
+ private final OutputStream _out;
- public ImageResponseStream(OutputStream out) {
- _out = out;
- }
-
- public void close() throws IOException {
- _out.flush();
- _out.close();
- }
-
- public void flush() throws IOException {
- _out.flush();
- }
-
- public void write(byte[] b, int off, int len) throws IOException {
- _out.write(b, off, len);
- }
-
- public void write(byte[] b) throws IOException {
- _out.write(b);
- }
-
- public void write(int b) throws IOException {
- _out.write(b);
- }
+ public ImageResponseStream(OutputStream out) {
+ _out = out;
+ }
+
+ public void close() throws IOException {
+ _out.flush();
+ _out.close();
+ }
+
+ public void flush() throws IOException {
+ _out.flush();
+ }
+
+ public void write(byte[] b, int off, int len) throws IOException {
+ _out.write(b, off, len);
+ }
+
+ public void write(byte[] b) throws IOException {
+ _out.write(b);
+ }
+
+ public void write(int b) throws IOException {
+ _out.write(b);
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/SimpleImageContext.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/SimpleImageContext.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/SimpleImageContext.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/graphicimagedynamic/util/SimpleImageContext.java Thu Jul 3 14:58:05 2008
@@ -22,27 +22,27 @@
import java.util.Map;
public class SimpleImageContext implements ImageContext {
-
- private final Map _params;
- private final Integer _width;
- private final Integer _height;
-
- public SimpleImageContext(Map params, Integer width, Integer height) {
- _params = params;
- _width = width;
- _height = height;
- }
-
- public Map getParamters() {
- return _params;
- }
-
- public Integer getWidth() {
- return _width;
- }
-
- public Integer getHeight() {
- return _height;
- }
+
+ private final Map _params;
+ private final Integer _width;
+ private final Integer _height;
+
+ public SimpleImageContext(Map params, Integer width, Integer height) {
+ _params = params;
+ _width = width;
+ _height = height;
+ }
+
+ public Map getParamters() {
+ return _params;
+ }
+
+ public Integer getWidth() {
+ return _width;
+ }
+
+ public Integer getHeight() {
+ return _height;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ifmessage/AbstractIfMessage.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ifmessage/AbstractIfMessage.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ifmessage/AbstractIfMessage.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ifmessage/AbstractIfMessage.java Thu Jul 3 14:58:05 2008
@@ -39,11 +39,11 @@
* @version $Revision$ $Date$
*/
public abstract class AbstractIfMessage extends UIComponentBase {
-
+
public static final String COMPONENT_TYPE = "org.apache.myfaces.IfMessage";
public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.IfMessageRenderer";
public static final String COMPONENT_FAMILY = "javax.faces.Panel";
-
+
/**
* @JSFProperty
* @return
@@ -51,33 +51,33 @@
public abstract String getFor();
private boolean isMessageForId(String id) {
- UIComponent component = findComponent(id);
- if(component != null) {
- String clientId = component.getClientId(FacesContext.getCurrentInstance());
- return FacesContext.getCurrentInstance().getMessages(clientId).hasNext();
- }
- return false;
+ UIComponent component = findComponent(id);
+ if(component != null) {
+ String clientId = component.getClientId(FacesContext.getCurrentInstance());
+ return FacesContext.getCurrentInstance().getMessages(clientId).hasNext();
+ }
+ return false;
+ }
+
+ public boolean getRendersChildren() {
+ return true;
}
- public boolean getRendersChildren() {
- return true;
- }
-
- public void encodeChildren(FacesContext context) throws IOException {
- if(getFor() != null) {
- StringTokenizer tokenizer = new StringTokenizer(getFor(), ",");
- while(tokenizer.hasMoreTokens()) {
- if(isMessageForId(tokenizer.nextToken().trim())) {
- super.encodeChildren(context);
- break;
- }
- }
- } else {
- if(FacesContext.getCurrentInstance().getMessages().hasNext()) {
- super.encodeChildren(context);
- }
- }
- }
+ public void encodeChildren(FacesContext context) throws IOException {
+ if(getFor() != null) {
+ StringTokenizer tokenizer = new StringTokenizer(getFor(), ",");
+ while(tokenizer.hasMoreTokens()) {
+ if(isMessageForId(tokenizer.nextToken().trim())) {
+ super.encodeChildren(context);
+ break;
+ }
+ }
+ } else {
+ if(FacesContext.getCurrentInstance().getMessages().hasNext()) {
+ super.encodeChildren(context);
+ }
+ }
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/isbnvalidator/ISBNValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/isbnvalidator/ISBNValidator.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/isbnvalidator/ISBNValidator.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/isbnvalidator/ISBNValidator.java Thu Jul 3 14:58:05 2008
@@ -40,53 +40,53 @@
public class ISBNValidator extends ValidatorBase {
- /**
- * <p>The standard converter id for this converter.</p>
- */
- public static final String VALIDATOR_ID = "org.apache.myfaces.validator.ISBN";
- /**
- * <p>The message identifier of the {@link FacesMessage} to be created if
- * the maximum length check fails.</p>
- */
- public static final String ISBN_MESSAGE_ID = "org.apache.myfaces.ISBN.INVALID";
-
- /**
- * <p>isbnValidator</p>
- */
- private org.apache.commons.validator.ISBNValidator isbnValidator;
-
- public ISBNValidator(){
- isbnValidator = new org.apache.commons.validator.ISBNValidator();
- }
-
- /**
- * methode that validates isbn codes.
- * it uses the commons-validator
- */
- public void validate(
- FacesContext facesContext,
- UIComponent uiComponent,
- Object value)
- throws ValidatorException {
-
-
- if (facesContext == null) throw new NullPointerException("facesContext");
- if (uiComponent == null) throw new NullPointerException("uiComponent");
-
- if (value == null)
- {
- return;
- }
+ /**
+ * <p>The standard converter id for this converter.</p>
+ */
+ public static final String VALIDATOR_ID = "org.apache.myfaces.validator.ISBN";
+ /**
+ * <p>The message identifier of the {@link FacesMessage} to be created if
+ * the maximum length check fails.</p>
+ */
+ public static final String ISBN_MESSAGE_ID = "org.apache.myfaces.ISBN.INVALID";
+
+ /**
+ * <p>isbnValidator</p>
+ */
+ private org.apache.commons.validator.ISBNValidator isbnValidator;
+
+ public ISBNValidator(){
+ isbnValidator = new org.apache.commons.validator.ISBNValidator();
+ }
+
+ /**
+ * methode that validates isbn codes.
+ * it uses the commons-validator
+ */
+ public void validate(
+ FacesContext facesContext,
+ UIComponent uiComponent,
+ Object value)
+ throws ValidatorException {
+
+
+ if (facesContext == null) throw new NullPointerException("facesContext");
+ if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+ if (value == null)
+ {
+ return;
+ }
if (!isbnValidator.isValid( value.toString())) {
- Object[] args = {value.toString()};
+ Object[] args = {value.toString()};
String message = getMessage();
if (null == message) message = ISBN_MESSAGE_ID;
throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, message, args));
- }
-
+ }
+
- }
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/loadbundle/AbstractLoadBundle.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/loadbundle/AbstractLoadBundle.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/loadbundle/AbstractLoadBundle.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/loadbundle/AbstractLoadBundle.java Thu Jul 3 14:58:05 2008
@@ -232,11 +232,11 @@
public boolean containsKey(Object key)
{
- try {
+ try {
return _bundle.getObject(key.toString()) != null;
- } catch (MissingResourceException e) {
- return false;
- }
+ } catch (MissingResourceException e) {
+ return false;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/media/MediaRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/media/MediaRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/media/MediaRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/media/MediaRenderer.java Thu Jul 3 14:58:05 2008
@@ -44,38 +44,38 @@
public class MediaRenderer extends Renderer {
public void encodeBegin(FacesContext context, UIComponent component)
- throws IOException {
+ throws IOException {
- MediaComponent mediaComponent = (MediaComponent) component;
+ MediaComponent mediaComponent = (MediaComponent) component;
- RendererUtils.checkParamValidity(context, component,
- MediaComponent.class);
+ RendererUtils.checkParamValidity(context, component,
+ MediaComponent.class);
- generateMediaTag(context, mediaComponent);
+ generateMediaTag(context, mediaComponent);
}
public void encodeEnd(FacesContext context, UIComponent component)
- throws IOException {
- super.encodeEnd(context, component);
+ throws IOException {
+ super.encodeEnd(context, component);
}
/*
* This helper method is used for generating the suitable media tag.
*/
private void generateMediaTag(FacesContext context,
- MediaComponent mediaComponent) throws IOException {
-
- String source = mediaComponent.getSource();
-
- /* if the src uri is an image then use the <img> tag */
- if(MediaUtil.isImage(source))
- {
- MediaUtil.generateImageTag(context, mediaComponent);
- }
- else /* generate EMBED Tag */
- {
- MediaUtil.generateEmbedTag(context, mediaComponent);
- }
-
+ MediaComponent mediaComponent) throws IOException {
+
+ String source = mediaComponent.getSource();
+
+ /* if the src uri is an image then use the <img> tag */
+ if(MediaUtil.isImage(source))
+ {
+ MediaUtil.generateImageTag(context, mediaComponent);
+ }
+ else /* generate EMBED Tag */
+ {
+ MediaUtil.generateEmbedTag(context, mediaComponent);
+ }
+
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/media/util/MediaUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/media/util/MediaUtil.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/media/util/MediaUtil.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/media/util/MediaUtil.java Thu Jul 3 14:58:05 2008
@@ -33,13 +33,13 @@
public class MediaUtil {
final static String[] IMAGES_EXTENSIONS = new String[] {
- "jpg",
- "jpeg",
- "png",
- "mng",
- "bmp",
- "gif",
- "dxf"
+ "jpg",
+ "jpeg",
+ "png",
+ "mng",
+ "bmp",
+ "gif",
+ "dxf"
};
/**
@@ -49,16 +49,16 @@
* @return boolean.
*/
public static boolean isImage(String uri) {
-
- for(int i = 0; i < IMAGES_EXTENSIONS.length; ++i)
- {
- if(uri.endsWith(IMAGES_EXTENSIONS[i]))
- {
- return true;
- }
- }
-
- return false;
+
+ for(int i = 0; i < IMAGES_EXTENSIONS.length; ++i)
+ {
+ if(uri.endsWith(IMAGES_EXTENSIONS[i]))
+ {
+ return true;
+ }
+ }
+
+ return false;
}
/**
@@ -69,50 +69,50 @@
* @throws IOException
*/
public static void generateEmbedTag(FacesContext context,
- MediaComponent mediaComponent) throws IOException {
+ MediaComponent mediaComponent) throws IOException {
+
+ ResponseWriter writer = context.getResponseWriter();
+ String source = mediaComponent.getSource();
+ String contentType = mediaComponent.getContentType();
+ String width = mediaComponent.getWidth();
+ String height = mediaComponent.getHeight();
+
+ /* start writing the media component */
+ writer.startElement(MediaConstants.EMBED_ELEM, mediaComponent);
+
+ writer.writeAttribute(HTML.ID_ATTR,
+ mediaComponent.getClientId(context), null);
+ writer.writeAttribute(HTML.NAME_ATTR, mediaComponent.getId(),
+ JSFAttr.ID_ATTR);
+
+ writer.writeAttribute(HTML.SRC_ATTR, source, null);
+
+ writer.writeAttribute(HTML.TYPE_ATTR, contentType, null);
- ResponseWriter writer = context.getResponseWriter();
- String source = mediaComponent.getSource();
- String contentType = mediaComponent.getContentType();
- String width = mediaComponent.getWidth();
- String height = mediaComponent.getHeight();
-
- /* start writing the media component */
- writer.startElement(MediaConstants.EMBED_ELEM, mediaComponent);
-
- writer.writeAttribute(HTML.ID_ATTR,
- mediaComponent.getClientId(context), null);
- writer.writeAttribute(HTML.NAME_ATTR, mediaComponent.getId(),
- JSFAttr.ID_ATTR);
-
- writer.writeAttribute(HTML.SRC_ATTR, source, null);
-
- writer.writeAttribute(HTML.TYPE_ATTR, contentType, null);
-
- /* write the rest of attributes */
-
- if (width != null && !"".equals(width)) {
- writer.writeAttribute(HTML.WIDTH_ATTR, width, null);
- }
-
- if (height != null && !"".equals(height)) {
- writer.writeAttribute(HTML.HEIGHT_ATTR, height, null);
- }
-
- writer.writeAttribute(MediaConstants.PLUGINSPAGE_ATTR,
- MediaConstants.DEFAULT_MEDIA_PLUGIN_PAGE, null);
- writer.writeAttribute(MediaConstants.SHOW_GOTO_BAR_ATTR, "true", null);
- writer.writeAttribute(MediaConstants.SHOW_DISPLAY_ATTR, "true", null);
- writer
- .writeAttribute(MediaConstants.SHOW_STATUS_BAR_ATTR, "true",
- null);
-
- /* if no EMBED not supported */
- writer.startElement(MediaConstants.NO_EMBED_ELEM, mediaComponent);
- writer.write("<a href=\"" +
- source +
- "\">EMBED is not supported, Click here to see the resource</a>");
- writer.endElement(MediaConstants.NO_EMBED_ELEM);
+ /* write the rest of attributes */
+
+ if (width != null && !"".equals(width)) {
+ writer.writeAttribute(HTML.WIDTH_ATTR, width, null);
+ }
+
+ if (height != null && !"".equals(height)) {
+ writer.writeAttribute(HTML.HEIGHT_ATTR, height, null);
+ }
+
+ writer.writeAttribute(MediaConstants.PLUGINSPAGE_ATTR,
+ MediaConstants.DEFAULT_MEDIA_PLUGIN_PAGE, null);
+ writer.writeAttribute(MediaConstants.SHOW_GOTO_BAR_ATTR, "true", null);
+ writer.writeAttribute(MediaConstants.SHOW_DISPLAY_ATTR, "true", null);
+ writer
+ .writeAttribute(MediaConstants.SHOW_STATUS_BAR_ATTR, "true",
+ null);
+
+ /* if no EMBED not supported */
+ writer.startElement(MediaConstants.NO_EMBED_ELEM, mediaComponent);
+ writer.write("<a href=\"" +
+ source +
+ "\">EMBED is not supported, Click here to see the resource</a>");
+ writer.endElement(MediaConstants.NO_EMBED_ELEM);
}
/**
@@ -123,34 +123,34 @@
* @throws IOException
*/
public static void generateImageTag(FacesContext context,
- MediaComponent mediaComponent) throws IOException {
+ MediaComponent mediaComponent) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- String source = mediaComponent.getSource();
- String width = mediaComponent.getWidth();
- String height = mediaComponent.getHeight();
+ ResponseWriter writer = context.getResponseWriter();
+ String source = mediaComponent.getSource();
+ String width = mediaComponent.getWidth();
+ String height = mediaComponent.getHeight();
- /* start writing the media component */
- writer.startElement(HTML.IMG_ELEM, mediaComponent);
+ /* start writing the media component */
+ writer.startElement(HTML.IMG_ELEM, mediaComponent);
- writer.writeAttribute(HTML.ID_ATTR, mediaComponent.getClientId(context), null);
- writer.writeAttribute(HTML.NAME_ATTR, mediaComponent.getId(), JSFAttr.ID_ATTR);
+ writer.writeAttribute(HTML.ID_ATTR, mediaComponent.getClientId(context), null);
+ writer.writeAttribute(HTML.NAME_ATTR, mediaComponent.getId(), JSFAttr.ID_ATTR);
- writer.writeAttribute(HTML.SRC_ATTR, source, null);
+ writer.writeAttribute(HTML.SRC_ATTR, source, null);
- /* write the rest of attributes */
+ /* write the rest of attributes */
- if (width != null && !"".equals(width))
- {
- writer.writeAttribute(HTML.WIDTH_ATTR, width, null);
- }
+ if (width != null && !"".equals(width))
+ {
+ writer.writeAttribute(HTML.WIDTH_ATTR, width, null);
+ }
- if (height != null && !"".equals(height))
- {
- writer.writeAttribute(HTML.HEIGHT_ATTR, height, null);
- }
+ if (height != null && !"".equals(height))
+ {
+ writer.writeAttribute(HTML.HEIGHT_ATTR, height, null);
+ }
- writer.endElement(HTML.IMG_ELEM);
+ writer.endElement(HTML.IMG_ELEM);
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/AbstractPasswordStrengthComponent.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/AbstractPasswordStrengthComponent.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/AbstractPasswordStrengthComponent.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/AbstractPasswordStrengthComponent.java Thu Jul 3 14:58:05 2008
@@ -49,48 +49,48 @@
public abstract class AbstractPasswordStrengthComponent extends HtmlInputText
implements AlignProperty{
- public static String COMPONENT_TYPE = "org.apache.myfaces.PasswordStrength";
+ public static String COMPONENT_TYPE = "org.apache.myfaces.PasswordStrength";
- public static String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.PasswordStrength";
-
- public static String COMPONENT_FAMILY = "org.apache.myfaces.PasswordStrength";
-
- /**
- * This flag {true | false} determines whether to show the details (left characters).
- * default is true
- *
- * @JSFProperty
- */
- public abstract String getShowDetails();
-
+ public static String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.PasswordStrength";
+
+ public static String COMPONENT_FAMILY = "org.apache.myfaces.PasswordStrength";
+
+ /**
+ * This flag {true | false} determines whether to show the details (left characters).
+ * default is true
+ *
+ * @JSFProperty
+ */
+ public abstract String getShowDetails();
+
/**
* This flag determines the indicator type. It can be {text or bar}. Default is text
*
* @JSFProperty
*/
- public abstract String getStrengthIndicatorType();
+ public abstract String getStrengthIndicatorType();
/**
* The prefered length of the password
*
* @JSFProperty
*/
- public abstract String getPreferredPasswordLength();
-
+ public abstract String getPreferredPasswordLength();
+
/**
* The prefix of the component message
*
* @JSFProperty
*/
- public abstract String getPrefixText();
-
+ public abstract String getPrefixText();
+
/**
* The text strength descriptions
*
* @JSFProperty
*/
- public abstract String getTextStrengthDescriptions();
-
+ public abstract String getTextStrengthDescriptions();
+
/**
* This string determines the expression of the custom security rule of the password
* <p>
@@ -129,7 +129,7 @@
*
* @JSFProperty
*/
- public abstract String getCustomSecurityExpression();
+ public abstract String getCustomSecurityExpression();
/**
* This flag determines whether to user custom security rules instead
@@ -137,8 +137,8 @@
*
* @JSFProperty
*/
- public abstract String getUseCustomSecurity();
-
+ public abstract String getUseCustomSecurity();
+
/**
* This attribute determines the penalty ratio that will decrease the password
* Strength if the custom security expression is not met. Note also that the
@@ -147,13 +147,13 @@
*
* @JSFProperty
*/
- public abstract String getPenaltyRatio();
-
+ public abstract String getPenaltyRatio();
+
/**
* HTML: Specifies the horizontal alignment of this element. Deprecated in HTML 4.01.
*
* @JSFProperty
*/
- public abstract String getAlign();
-
+ public abstract String getAlign();
+
}