org.jboss.portletbridge.PlainJsfStrategy Maven / Gradle / Ivy
/**
*
*/
package org.jboss.portletbridge;
import java.io.IOException;
import java.util.logging.Logger;
import javax.faces.application.Application;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.render.RenderKitFactory;
import javax.portlet.PortletSession;
import javax.portlet.RenderResponse;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import javax.portlet.faces.BridgeException;
import org.jboss.portletbridge.component.UIPortletViewRoot;
import org.jboss.portletbridge.util.BridgeLogger;
/**
* @author asmirnov
*
*/
public class PlainJsfStrategy extends BridgeStrategy {
private static final Logger log = BridgeLogger.BRIDGE.getLogger();
public PlainJsfStrategy(BridgeConfig config) {
super(config);
}
public void init(FacesContext context,
RenderKitFactory renderKitFactory) {
Application application = context.getApplication();
application.addComponent(UIViewRoot.COMPONENT_TYPE,
UIPortletViewRoot.class.getName());
}
public void beforeRenderRequest(FacesContext facesContext) {
// Do nothing
}
public RenderResponse createResponseWrapper(RenderResponse response) {
return new BufferedRenderResponseWrapper(response);
}
public ResourceResponse createResponseWrapper(ResourceResponse response) {
return new BufferedResourceResponseWrapper(response);
}
public void afterRenderRequest(FacesContext facesContext,
RenderResponse wrappedResponse) {
try {
((BufferedMimeResponseWrapper) wrappedResponse).writeBufferedData();
} catch (IOException e) {
throw new BridgeException("Error writing buffered data ",e);
}
}
@Override
public void beforeResourceRequest(FacesContext facesContext) {
// DO nothing
}
@Override
public void afterResourceRequestExecute(FacesContext facesContext) {
// TODO save portlet state
}
public void afterResourceRequest(FacesContext facesContext,
ResourceResponse wrappedResponse) {
try {
((BufferedMimeResponseWrapper) wrappedResponse).writeBufferedData();
} catch (IOException e) {
throw new BridgeException("Error writing buffered data ",e);
}
}
@Override
public boolean serveResource(ResourceRequest request,
ResourceResponse response) throws BridgeException {
// JSF has no resources service.
return false;
}
@Override
public int getPortletSessionScopeForName(String name) {
return PortletSession.PORTLET_SCOPE;
}
@Override
public void beforeActionRequest(FacesContext facesContext) {
// DO nothing
}
@Override
public void afterActionRequestExecute(FacesContext facesContext) {
// DO Nothing
}
@Override
public void afterActionRequest(FacesContext facesContext) {
// DO nothing
}
@Override
public void beforeEventRequest(FacesContext facesContext) {
// DO nothing
}
@Override
public void afterEventRequest(FacesContext facesContext) {
// DO nothing
}
@Override
public UIViewRoot createViewRoot() {
return new UIPortletViewRoot();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy