use of javax.faces.render.Renderer in project liferay-faces-alloy by liferay.
the class AbstractButtonRenderer method encodeChildren.
@Override
public void encodeChildren(FacesContext facesContext, UIComponent uiComponent) throws IOException {
if (hasMenu(uiComponent)) {
UIComponent nodeMenuNav = NodeMenuNavFactory.getNodeMenuNav(uiComponent);
RenderKit renderKit = facesContext.getRenderKit();
Renderer nodeMenuNavRenderer = renderKit.getRenderer(nodeMenuNav.getFamily(), nodeMenuNav.getRendererType());
nodeMenuNavRenderer.encodeChildren(facesContext, nodeMenuNav);
} else {
ResponseWriter responseWriter = facesContext.getResponseWriter();
Map<String, Object> attributes = uiComponent.getAttributes();
// Do not delegate the writing of the image attribute because the image needs to be a child rather than an
// attribute of the button.
String image = (String) attributes.get(IMAGE);
if (image != null) {
String src = (String) facesContext.getAttributes().remove(FACES_RUNTIME_SRC);
if (src != null) {
responseWriter.startElement("img", uiComponent);
responseWriter.writeAttribute("src", src, IMAGE);
responseWriter.endElement("img");
}
} else {
if (getVisualChildCount(uiComponent) == 0) {
// Do not delegate the writing of the value attribute because the value needs to be a child rather
// than an attribute of the button.
Object value = (String) attributes.get("value");
if (value != null) {
responseWriter.writeText(value.toString(), "value");
}
}
}
super.encodeChildren(facesContext, uiComponent);
}
}
use of javax.faces.render.Renderer in project liferay-faces-bridge-impl by liferay.
the class ResourceRendererImplTest method testSaveRestoreStateFACES_3280.
@Test
public void testSaveRestoreStateFACES_3280() {
Renderer renderer = new RendererMockImpl();
ResourceRendererImpl resourceRendererImpl = new ResourceRendererImpl(renderer);
Object state = resourceRendererImpl.saveState(null);
Assert.assertEquals(renderer.getClass(), state);
resourceRendererImpl = new ResourceRendererImpl();
Assert.assertNull(resourceRendererImpl.getWrapped());
resourceRendererImpl.restoreState(null, state);
Assert.assertNotNull(resourceRendererImpl.getWrapped());
}
use of javax.faces.render.Renderer in project primefaces by primefaces.
the class UIData method encodeBegin.
@Override
public void encodeBegin(FacesContext context) throws IOException {
preEncode(context);
if (context == null) {
throw new NullPointerException();
}
pushComponentToEL(context, null);
if (!isRendered()) {
return;
}
context.getApplication().publishEvent(context, PreRenderComponentEvent.class, this);
String rendererType = getRendererType();
if (rendererType != null) {
Renderer renderer = getRenderer(context);
if (renderer != null) {
renderer.encodeBegin(context, this);
}
}
}
use of javax.faces.render.Renderer in project primefaces by primefaces.
the class CascadeSelect method queueEvent.
@Override
public void queueEvent(FacesEvent event) {
FacesContext context = getFacesContext();
if (ComponentUtils.isRequestSource(this, context) && event instanceof AjaxBehaviorEvent) {
Map<String, String> params = context.getExternalContext().getRequestParameterMap();
String eventName = params.get(Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM);
FacesEvent wrapperEvent = null;
AjaxBehaviorEvent behaviorEvent = (AjaxBehaviorEvent) event;
if ("itemSelect".equals(eventName)) {
Renderer renderer = ComponentUtils.getUnwrappedRenderer(context, "javax.faces.SelectOne", "javax.faces.Listbox");
Object item = renderer.getConvertedValue(context, this, getSubmittedValue());
wrapperEvent = new SelectEvent(this, behaviorEvent.getBehavior(), item);
wrapperEvent.setPhaseId(behaviorEvent.getPhaseId());
}
super.queueEvent(wrapperEvent);
} else {
super.queueEvent(event);
}
}
use of javax.faces.render.Renderer in project primefaces by primefaces.
the class UITabPanel method process.
public void process(FacesContext faces, PhaseId phase) {
// stop if not rendered
if (!isRendered()) {
return;
}
// validate attributes
validateAttributes();
// reset index
captureScopeValues();
setIndex(-1);
try {
// has children
if (getChildCount() > 0) {
boolean dynamic = isDynamic();
int i = getOffset();
int end = getSize();
int step = getStep();
end = (end >= 0) ? i + end : Integer.MAX_VALUE - 1;
// grab renderer
String rendererType = getRendererType();
Renderer renderer = null;
if (rendererType != null) {
renderer = getRenderer(faces);
}
_count = 0;
setIndex(i);
while (i <= end && isIndexAvailable()) {
if (PhaseId.RENDER_RESPONSE.equals(phase) && renderer != null) {
renderer.encodeChildren(faces, this);
} else {
for (int j = 0, childCount = getChildCount(); j < childCount; j++) {
UIComponent child = getChildren().get(j);
if (dynamic && child instanceof Tab && !((Tab) child).isLoaded(i)) {
continue;
}
if (PhaseId.APPLY_REQUEST_VALUES.equals(phase)) {
child.processDecodes(faces);
} else if (PhaseId.PROCESS_VALIDATIONS.equals(phase)) {
child.processValidators(faces);
} else if (PhaseId.UPDATE_MODEL_VALUES.equals(phase)) {
child.processUpdates(faces);
} else if (PhaseId.RENDER_RESPONSE.equals(phase)) {
child.encodeAll(faces);
}
}
}
++_count;
i += step;
setIndex(i);
}
}
} catch (IOException e) {
throw new FacesException(e);
} finally {
setIndex(-1);
restoreScopeValues();
}
}
Aggregations