Renderer WM7 Portal SP2

Hi,

I am currently working with Renderers on WM7 Portal SP2. I was able to make a custom Renderer for several JSF UI Component.

Now, what I am trying to do is to delegate some rendering to the default Renderer. I tried to do that based on this article from Sun :

http://java.sun.com/developer/technicalArticles/J2EE/jsf_renderers/

This is my code:

#####################CODE########################

package com.emergis.pnp.portal.renderer_portlet;

import java.io.IOException;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.render.Renderer;

public class ButtonRenderer extends Renderer{

@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
	
	Renderer baseRenderer = context.getRenderKit().getRenderer("javax.faces.Command", "javax.faces.Button");
	baseRenderer.encodeEnd(context, component);

}

@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {

	
	Renderer baseRenderer = context.getRenderKit().getRenderer("javax.faces.Command", "javax.faces.Button");
	baseRenderer.encodeBegin(context, component);
}

}

#####################CODE########################

After deployment, I get this error after loading the portlet :

  • [POP.001.0002] A “javax.portlet.PortletException” occurred with the Message “at com.webmethods.caf.faces.portlet.FacesPortlet.render(FacesPortlet.java:408)”
  • java.lang.StackOverflowError

I know that I get this error because I am calling recursively encodeBegin() and encodeEnd(). Base on this, is there another way to delegate the rendering to the default renderer?

Thanks,

Paul

Hi,

I found out where my exception comes from. It is because I am overriding the default renderer of javax.faces.Button and my renderer becomes the base renderer. So when I call it, it calls itself recursively. This is why there is a stack overflow.

Although I understand what causes this exception, my problem is still unsolved.

How can I create a custom renderer in WM7 basing on the default renderer of the component without overriding it?

I am able to create a custom renderer in a JSF webapp by creating a Tag class, with a new component type, and use the tags inside my JSP file (cannot be done inside a WM7 .view file). How can I accomplish this in WM7?

Thank you and hope to hear from someone soon!

Paul

Hi,

I still have no clue how I could do this. (to create a custom renderer in WM7 basing on the default renderer of a component) Any help?

Thanks

MWS 7 does not support visual editing with custom components/renderers. However, if you register your custom components/renderers in your webapp’s faces-config.xml file, you can manually edit .view files to use your custom components/renderers.

For example, if you edit a .view file with a CommandButton control, you’ll see something like this:

You can replace the “renderer-type” attribute value with the renderer type of a renderer you registered in your faces-config.xml. You can also add arbitrary property elements to specify arbitrary component attributes which your custom renderer may use:

In your custom renderer encodeBegin() or encodeEnd() method, you could access the “myCustomAttribute” attribute via the following code:

public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
Object myCustomAttribute = component.getAttributes().get(“myCustomAttribute”);
// …
}

Sorry, you’ll have to find the above post in the html page source to see the .view file xml snippets.