Methods Summary |
---|
public java.util.Locale | calculateLocale(javax.faces.context.FacesContext context)Delegates the call to the previously registered ViewHandler.
return origViewHandler.calculateLocale(context);
|
public java.lang.String | calculateRenderKitId(javax.faces.context.FacesContext context)Delegates the call to the previously registered ViewHandler.
return origViewHandler.calculateRenderKitId(context);
|
public javax.faces.component.UIViewRoot | createView(javax.faces.context.FacesContext context, java.lang.String viewId)Returns the UIViewRoot for the specified view ID, created
by the createViewRoot() method, with the "locale" and
"renderKitId" properties initialized.
String realViewId = viewId;
if (viewId.indexOf(".") != -1) {
realViewId = viewId.substring(0, viewId.indexOf("."));
}
UIViewRoot viewRoot = createViewRoot(context, realViewId);
if (viewRoot != null) {
if (context.getViewRoot() != null) {
UIViewRoot oldRoot = context.getViewRoot();
viewRoot.setLocale(oldRoot.getLocale());
viewRoot.setRenderKitId(oldRoot.getRenderKitId());
}
else {
ViewHandler activeVH =
context.getApplication().getViewHandler();
viewRoot.setLocale(activeVH.calculateLocale(context));
viewRoot.setRenderKitId(activeVH.calculateRenderKitId(context));
}
}
return viewRoot;
|
protected javax.faces.component.UIViewRoot | createViewRoot(javax.faces.context.FacesContext context, java.lang.String viewId)Returns the UIViewRoot for the view created by the View instance
matching the view ID.
UIViewRoot viewRoot = null;
View view = (View) views.get(viewId);
if (view == null) {
if ("/subscribe".equals(viewId)) {
view = new SubscribeView();
views.put(viewId, view);
}
}
if (view != null) {
viewRoot = view.createView(context);
viewRoot.setViewId(viewId);
}
return viewRoot;
|
public java.lang.String | getActionURL(javax.faces.context.FacesContext context, java.lang.String viewId)Delegates the call to the previously registered ViewHandler.
return origViewHandler.getActionURL(context, viewId);
|
public java.lang.String | getResourceURL(javax.faces.context.FacesContext context, java.lang.String path)Delegates the call to the previously registered ViewHandler.
return origViewHandler.getResourceURL(context, path);
|
protected void | renderResponse(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)Recursively renders the provided component and all its children
by calling encodeBegin(), encodeChildren() (if the component
renders its children) and encodeEnd().
component.encodeBegin(context);
if (component.getRendersChildren()) {
component.encodeChildren(context);
}
else {
Iterator i = component.getChildren().iterator();
while (i.hasNext()) {
renderResponse(context, (UIComponent) i.next());
}
}
component.encodeEnd(context);
|
public void | renderView(javax.faces.context.FacesContext context, javax.faces.component.UIViewRoot viewToRender)Gets the view state to save, if any, and puts a reference to
the state in a request scope variable where it can be picked
up by the writeState() method, and renders the view represented
by the provided UIViewRoot instance by calling renderResponse().
setupResponseWriter(context);
StateManager sm = context.getApplication().getStateManager();
SerializedView state = sm.saveSerializedView(context);
context.getExternalContext().getRequestMap().put(STATE_VAR, state);
context.getResponseWriter().startDocument();
renderResponse(context, viewToRender);
context.getResponseWriter().endDocument();
|
public javax.faces.component.UIViewRoot | restoreView(javax.faces.context.FacesContext context, java.lang.String viewId)Returns the UIViewRoot for the restored view identified by
the provided view ID, or null if no state is available.
String realViewId = viewId;
if (viewId.indexOf(".") != -1) {
realViewId = viewId.substring(0, viewId.indexOf("."));
}
String renderKitId =
context.getApplication().getViewHandler().
calculateRenderKitId(context);
StateManager sm = context.getApplication().getStateManager();
return sm.restoreView(context, realViewId, renderKitId);
|
private void | setupResponseWriter(javax.faces.context.FacesContext context)Asks the current RenderKit to create a ResponseWriter around
the OutputStream for the response body and sets the
Content-Type response header to the MIME type selected by
the ResponseWriter from the alternatives listed in the
Accept request header.
ServletResponse response = (ServletResponse)
context.getExternalContext().getResponse();
OutputStream os = response.getOutputStream();
Map headers = context.getExternalContext().getRequestHeaderMap();
String acceptHeader = (String) headers.get("Accept");
// Work-around for JSF 1.0 RI bug: failing to accept "*/*" and
// and "text/*" as valid replacements for "text/html"
if (acceptHeader != null &&
(acceptHeader.indexOf("*/*") != -1 ||
acceptHeader.indexOf("text/*") != -1)) {
acceptHeader += ",text/html";
}
RenderKitFactory renderFactory = (RenderKitFactory)
FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
RenderKit renderKit =
renderFactory.getRenderKit(context,
context.getViewRoot().getRenderKitId());
ResponseWriter writer =
renderKit.createResponseWriter(new OutputStreamWriter(os),
acceptHeader, response.getCharacterEncoding());
context.setResponseWriter(writer);
response.setContentType(writer.getContentType());
|
public void | writeState(javax.faces.context.FacesContext context)Writes the state captured and saved by the renderView() method
to the response with the help of the current StateManager.
SerializedView state = (SerializedView)
context.getExternalContext().getRequestMap().get(STATE_VAR);
if (state != null) {
StateManager sm = context.getApplication().getStateManager();
sm.writeState(context, state);
}
|