本文整理汇总了Java中javax.faces.render.Renderer类的典型用法代码示例。如果您正苦于以下问题:Java Renderer类的具体用法?Java Renderer怎么用?Java Renderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Renderer类属于javax.faces.render包,在下文中一共展示了Renderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeEnd
import javax.faces.render.Renderer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void encodeEnd(FacesContext context,
UIComponent component) throws IOException
{
// The tr:commandLink is not a rendersChildren component,
// but h:commandLink is. Hence, the difference in behavior
Renderer renderer = createRenderer(component);
renderer.encodeBegin(context, component);
for(UIComponent child : (List<UIComponent>)component.getChildren())
{
RenderUtils.encodeRecursive(context, child);
}
renderer.encodeEnd(context, component);
}
示例2: _isFullRow
import javax.faces.render.Renderer; //导入依赖的package包/类
/**
* Retrieves whether the child renderer can and should render a complete form
* layout row specifically structured for the panelFormLayout.
* @return true if the child can and should render a complete form
* layout row specifically structured for the panelFormLayout
*/
private boolean _isFullRow(
FacesContext context,
UIComponent component)
{
String rendererType = component.getRendererType();
if (component instanceof UIXEditableValue)
{
return !_UNSUPPORTED_RENDERER_TYPES.contains(rendererType);
}
if (UIXPanel.COMPONENT_FAMILY.equals(component.getFamily()))
{
if ("org.apache.myfaces.trinidad.LabelAndMessage".equals(rendererType) ||
"org.apache.myfaces.trinidad.rich.LabelAndMessage".equals(rendererType))
return true;
}
Renderer renderer = _getRenderer(context, component);
if(renderer == null)
return false;
else
return renderer instanceof LabelAndMessageRenderer;
}
示例3: _processPassThroughAttributes
import javax.faces.render.Renderer; //导入依赖的package包/类
private String _processPassThroughAttributes(String name, Map<String, Object> passThroughAttributes)
{
if (passThroughAttributes != null)
{
Object value = passThroughAttributes.get(Renderer.PASSTHROUGH_RENDERER_LOCALNAME_KEY);
if (value instanceof ValueExpression)
{
value = ((ValueExpression)value).getValue(FacesContext.getCurrentInstance().getELContext());
}
if (value != null)
{
String elementName = value.toString();
if (!name.equals(elementName)) {
name = elementName;
}
}
}
return name;
}
示例4: _processPassThroughAttributes
import javax.faces.render.Renderer; //导入依赖的package包/类
private String _processPassThroughAttributes(String name, UIComponent component) {
if (component == null) {
return name;
}
_passThroughAttributes = component.getPassThroughAttributes(false);
if (_passThroughAttributes != null)
{
Object value = _passThroughAttributes.get(Renderer.PASSTHROUGH_RENDERER_LOCALNAME_KEY);
if (value instanceof ValueExpression)
{
value = ((ValueExpression)value).getValue(FacesContext.getCurrentInstance().getELContext());
}
if (value != null)
{
String elementName = value.toString();
if (!name.equals(elementName)) {
name = elementName;
}
}
}
return name;
}
示例5: testRendererLocalNamePassThroughAttribute
import javax.faces.render.Renderer; //导入依赖的package包/类
public void testRendererLocalNamePassThroughAttribute() throws Exception
{
_responseWriter.startDocument();
HtmlInputText inputText = new HtmlInputText();
inputText.getPassThroughAttributes().put(Renderer.PASSTHROUGH_RENDERER_LOCALNAME_KEY, "test");
_responseWriter.startElement("div", inputText);
_responseWriter.startElement("div", null);
_responseWriter.startElement("input", null);
_responseWriter.writeAttribute("name", "test", null);
_responseWriter.endElement("input");
_responseWriter.endElement("div");
_responseWriter.endElement("div");
_responseWriter.endDocument();
Assert.assertEquals("<?xml version='1.0' encoding='UTF-8'?>\n" +
"<partial-response id=\"j_id1\"><test><div><input name=\"test\"/></div></test></partial-response>", _stringWriter.toString());
}
示例6: getRendererClientId
import javax.faces.render.Renderer; //导入依赖的package包/类
/**
* Returns the clientId used by the renderer in place of the clientId used by the component.
* Certain renderers render their root element with a clientId that differs from the one
* used by the component.
* @param context FacesContent.
* @param component UIComponent.
* @return component clientId if the renderer clientId is null. Otherwise clientId used by
* renderer.
*/
public static String getRendererClientId(
FacesContext context,
UIComponent component)
{
String clientId = component.getClientId(context);
String family = component.getFamily();
String rendererType = component.getRendererType();
if (rendererType != null)
{
Renderer renderer = context.getRenderKit().getRenderer(family, rendererType);
if (renderer instanceof CoreRenderer)
{
CoreRenderer coreRenderer = (CoreRenderer) renderer;
String rendererClientId = coreRenderer.getClientId(context, component);
return rendererClientId == null ? clientId : rendererClientId;
}
}
return clientId;
}
示例7: encodeBegin
import javax.faces.render.Renderer; //导入依赖的package包/类
@Override
public void encodeBegin(FacesContext context) throws IOException
{
if (context == null)
throw new NullPointerException();
// Call UIComponent.pushComponentToEL(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
pushComponentToEL(context, this);
if (!isRendered())
return;
context.getApplication().publishEvent(context, PreRenderComponentEvent.class, UIComponent.class, this);
_cacheRenderer(context);
Renderer renderer = getRenderer(context);
// if there is a Renderer for this component
if (renderer != null)
{
renderer.encodeBegin(context, this);
}
}
示例8: encodeChildren
import javax.faces.render.Renderer; //导入依赖的package包/类
@Override
public void encodeChildren(FacesContext context) throws IOException
{
if (context == null)
throw new NullPointerException();
if (!isRendered())
return;
Renderer renderer = getRenderer(context);
// if there is a Renderer for this component
if (renderer != null)
{
renderer.encodeChildren(context, this);
}
}
示例9: _getRendererImpl
import javax.faces.render.Renderer; //导入依赖的package包/类
private Renderer _getRendererImpl(FacesContext context)
{
String rendererType = getRendererType();
if (rendererType != null)
{
RenderKit renderKit = context.getRenderKit();
Renderer renderer = renderKit.getRenderer(getFamily(), rendererType);
if (renderer == null)
{
_LOG.warning("CANNOT_FIND_RENDERER", new Object[]{this, rendererType});
}
return renderer;
}
return null;
}
示例10: visitChildren
import javax.faces.render.Renderer; //导入依赖的package包/类
/**
* Hook for subclasses to override the manner in which the component's children are visited. The default
* implementation visits all of the children and facets of the Component.
* <code>setupChildrenVisitingContext</code> will have been called before this method is
* invoked and <code>tearDownChildrenVisitingContext</code> will be called after.
* respectively. If the purpose of this visit was to encode the component and the
* component uses a CoreRenderer, the CoreRenderer's
* <code>setupChildrenEncodingContext</code> and <code>tearDownChildrenEncodingContext</code>
* will be called before and after this method is invoked, respectively.
* @param visitContext the <code>VisitContext</code> for this visit
* @param callback the <code>VisitCallback</code> instance
* @return <code>true</code> if the visit is complete.
* @see #setupChildrenVisitingContext
* @see #tearDownChildrenVisitingContext
* @see org.apache.myfaces.trinidad.render.CoreRenderer#setupChildrenEncodingContext
* @see org.apache.myfaces.trinidad.render.CoreRenderer#tearDownChildrenEncodingContext
*/
protected boolean visitChildren(
VisitContext visitContext,
VisitCallback callback)
{
// See if this is during encoding, if so, allow the renderer to control the visitation of
// the children so that any special encoding context may be applied around the visitation
// of each child.
if (_isEncodingVisit(visitContext))
{
Renderer renderer = getRenderer(visitContext.getFacesContext());
if (renderer instanceof CoreRenderer)
{
CoreRenderer coreRenderer = (CoreRenderer)renderer;
return coreRenderer.visitChildrenForEncoding(this, visitContext, callback);
}
}
// visit all of the children of the component
return visitAllChildren(visitContext, callback);
}
示例11: getClientRowKeyManager
import javax.faces.render.Renderer; //导入依赖的package包/类
/**
* Gets the ClientRowKeyManager that is used to handle the
* {@link #getClientRowKey} and
* {@link #setClientRowKey} methods.
* If the manager does not already exist a new one is created.
* In order to create your own manager, your Renderer (for this component)
* must implement
* {@link ClientRowKeyManagerFactory}
*/
public final ClientRowKeyManager getClientRowKeyManager()
{
// this method must be public, because specific renderers
// need access to the ClientRowKeyManager so that they might prune it.
InternalState iState = _getInternalState(true);
if (iState._clientKeyMgr == null)
{
FacesContext fc = FacesContext.getCurrentInstance();
Renderer r = getRenderer(fc);
iState._clientKeyMgr = (r instanceof ClientRowKeyManagerFactory)
? ((ClientRowKeyManagerFactory) r).createClientRowKeyManager(fc, this)
: new DefaultClientKeyManager();
}
return iState._clientKeyMgr;
}
示例12: doTestValidateFailure
import javax.faces.render.Renderer; //导入依赖的package包/类
protected void doTestValidateFailure(
UIViewRoot root)
{
// -= Simon =-
// All those variables do not seem to be used and do not seem
// to test anything either
/*Mock mockRenderkit = getMockRenderKitWrapper().getMock();
RenderKit renderkit = getMockRenderKitWrapper().getRenderKit();
*/
Mock mockRenderer = mock(Renderer.class);
/*Renderer renderer = (Renderer) mockRenderer.proxy();
Mock mockValidator = mock(Validator.class);
Validator validator = (Validator) mockValidator.proxy();
ViewHandler viewhandler = this.facesContext.getApplication().getViewHandler();*/
setCurrentContext(facesContext);
root.processValidators(facesContext);
mockRenderer.verify();
setCurrentContext(null);
}
示例13: mockFacesContext
import javax.faces.render.Renderer; //导入依赖的package包/类
public static FacesContext mockFacesContext() {
FacesContext context = Mockito.mock(FacesContext.class);
Application application = Mockito.mock(Application.class);
ExternalContext external = Mockito.mock(ExternalContext.class);
ResourceBundle bundle = Mockito.mock(ResourceBundle.class);
RenderKit renderKit = Mockito.mock(RenderKit.class);
UIViewRoot viewRoot = Mockito.mock(UIViewRoot.class);
ELContext elContext = Mockito.mock(ELContext.class);
when(context.getApplication()).thenReturn(application);
when(context.getExternalContext()).thenReturn(external);
when(application.getResourceBundle(context, MessageProvider.BUNDLE_KEY)).thenReturn(bundle);
when(context.getRenderKit()).thenReturn(renderKit);
when(context.getViewRoot()).thenReturn(viewRoot);
when(context.getELContext()).thenReturn(elContext);
when(renderKit.getRenderer(Matchers.anyString(), Matchers.anyString())).thenReturn(Mockito.mock(Renderer.class));
setCurrentInstance(context);
Mockito.doAnswer(RELEASE).when(context).release();
return context;
}
示例14: encodeBegin
import javax.faces.render.Renderer; //导入依赖的package包/类
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
String newRendererType = detectNewRendererType(context, component);
// modify the control, so that this renderer won't be used in future,
// avoiding the overhead of delegation. Once this encode phase ends
// the detected renderer will be used instead of this renderer.
component.setRendererType(newRendererType);
// save the value for use in encodeChildren and encodeEnd.
HtmlUtil.storeEncodeParameter(context, component, "newRendererType", newRendererType); //$NON-NLS-1$
// the default implementation here and in the rest of the methods
// is to delegate the rendering & decoding to the detected renderer
Renderer delegate = findDelegate(context, component, newRendererType);
delegate.encodeBegin(context, component);
}
示例15: addRenderer
import javax.faces.render.Renderer; //导入依赖的package包/类
/**
* <p>Add a new {@link Renderer} instance, associated with the
* specified <code>rendererType</code>, to the set of
* {@link Renderer}s registered with this {@link RenderKit}.
*
* @param rendererType Renderer type of the new {@link Renderer}
* @param renderer The new {@link Renderer} instance
*
* @exception IllegalArgumentException if a {@link Renderer} with the
* specified <code>rendererType</code> has already been registered
* @exception NullPointerException if <code>rendererType</code> or
* <code>renderer</code> is null
*/
@Override
public void addRenderer(
String family,
String rendererType,
Renderer renderer)
{
/* =-=AEW No: it is legal to override a renderer.
if ( _get(family, rendererType) != null )
throw new IllegalArgumentException(_LOG.getMessage(
"DUPLICATE_RENDERER_TYPE", new Object[]{rendererType, family}));
*/
_put(family, rendererType, renderer);
}