use of javax.faces.render.Renderer in project primefaces by primefaces.
the class UIData method getClientId.
@Override
public String getClientId(FacesContext context) {
if (clientId != null) {
return clientId;
}
String id = getId();
if (id == null) {
UniqueIdVendor parentUniqueIdVendor = ComponentTraversalUtils.closestUniqueIdVendor(this);
if (parentUniqueIdVendor == null) {
UIViewRoot viewRoot = context.getViewRoot();
if (viewRoot != null) {
id = viewRoot.createUniqueId();
} else {
throw new FacesException("Cannot create clientId for " + getClass().getCanonicalName());
}
} else {
id = parentUniqueIdVendor.createUniqueId(context, null);
}
setId(id);
}
UIComponent namingContainer = ComponentTraversalUtils.closestNamingContainer(this);
if (namingContainer != null) {
String containerClientId = namingContainer.getContainerClientId(context);
if (containerClientId != null) {
StringBuilder sb = SharedStringBuilder.get(context, SB_ID, containerClientId.length() + 10);
clientId = sb.append(containerClientId).append(UINamingContainer.getSeparatorChar(context)).append(id).toString();
} else {
clientId = id;
}
} else {
clientId = id;
}
Renderer renderer = getRenderer(context);
if (renderer != null) {
clientId = renderer.convertClientId(context, clientId);
}
return clientId;
}
use of javax.faces.render.Renderer in project primefaces by primefaces.
the class UIRepeat method process.
public void process(FacesContext faces, PhaseId phase) {
// stop if not rendered
if (!this.isRendered())
return;
PrimeEnvironment environment = PrimeApplicationContext.getCurrentInstance(faces).getEnvironment();
if (environment.isMojarra()) {
LOGGER.log(Level.WARNING, "Mojarra versions 2.3.18, 3.0.3, and 4.0+ do not require p:repeat, " + "please upgrade and switch to ui:repeat.");
} else {
LOGGER.log(Level.WARNING, "Apache MyFaces does not require p:repeat, please switch to ui:repeat.");
}
// clear datamodel
this.resetDataModel();
// We must clear the child state if we just entered the Render Phase, and there are no error messages
if (PhaseId.RENDER_RESPONSE.equals(phase) && !hasErrorMessages(faces)) {
this.clearChildState();
}
// reset index
this.captureOrigValue(faces);
this.setIndex(faces, -1);
try {
// has children
if (this.getChildCount() > 0) {
Iterator itr;
UIComponent c;
Integer begin = this.getBegin();
Integer step = this.getStep();
Integer end = this.getEnd();
Integer offset = this.getOffset();
if (null != offset && offset > 0) {
begin = offset;
}
Integer size = this.getSize();
if (null != size) {
end = size;
}
// grab renderer
String rendererType = getRendererType();
Renderer renderer = null;
if (rendererType != null) {
renderer = getRenderer(faces);
}
int rowCount = getDataModel().getRowCount();
int i = ((begin != null) ? begin : 0);
int e = ((end != null) ? end : rowCount);
int s = ((step != null) ? step : 1);
validateIterationControlValues(rowCount, i, e);
if (null != size && size > 0) {
e = size - 1;
}
this.setIndex(faces, i);
this.updateIterationStatus(faces, new IterationStatus(true, (i + s > e || rowCount == 1), i, begin, end, step));
while (i <= e && this.isIndexAvailable()) {
if (PhaseId.RENDER_RESPONSE.equals(phase) && renderer != null) {
renderer.encodeChildren(faces, this);
} else {
itr = this.getChildren().iterator();
while (itr.hasNext()) {
c = (UIComponent) itr.next();
if (PhaseId.APPLY_REQUEST_VALUES.equals(phase)) {
c.processDecodes(faces);
} else if (PhaseId.PROCESS_VALIDATIONS.equals(phase)) {
c.processValidators(faces);
} else if (PhaseId.UPDATE_MODEL_VALUES.equals(phase)) {
c.processUpdates(faces);
} else if (PhaseId.RENDER_RESPONSE.equals(phase)) {
c.encodeAll(faces);
}
}
}
i += s;
this.setIndex(faces, i);
this.updateIterationStatus(faces, new IterationStatus(false, i + s >= e, i, begin, end, step));
}
}
} catch (IOException e) {
throw new FacesException(e);
} finally {
this.setIndex(faces, -1);
this.restoreOrigValue(faces);
}
/*
* Once rendering is done we need to make sure the child components
* are not still having client ids that use an index.
*/
if (PhaseId.RENDER_RESPONSE.equals(phase)) {
resetClientIds(this);
}
}
use of javax.faces.render.Renderer in project primefaces by primefaces.
the class SelectOneMenu method queueEvent.
@Override
public void queueEvent(FacesEvent event) {
if (event instanceof AjaxBehaviorEvent) {
FacesContext context = getFacesContext();
AjaxBehaviorEvent behaviorEvent = (AjaxBehaviorEvent) event;
Map<String, String> params = context.getExternalContext().getRequestParameterMap();
String eventName = params.get(Constants.RequestParams.PARTIAL_BEHAVIOR_EVENT_PARAM);
if ("itemSelect".equals(eventName)) {
Renderer renderer = ComponentUtils.getUnwrappedRenderer(context, "javax.faces.SelectOne", "javax.faces.Menu");
Object item = renderer.getConvertedValue(context, this, getSubmittedValue());
SelectEvent selectEvent = new SelectEvent(this, behaviorEvent.getBehavior(), item);
selectEvent.setPhaseId(event.getPhaseId());
super.queueEvent(selectEvent);
} else {
super.queueEvent(event);
}
} else {
super.queueEvent(event);
}
}
use of javax.faces.render.Renderer in project gdmatrix by gdmatrix.
the class FCKFaceEditor method encodeEnd.
/**
* Moved to encode end so that the inline java script will run after the textArea was rendered before this script is run
* @param context
* @throws IOException
*/
public void encodeEnd(FacesContext context) throws IOException {
String editorRenderer = DEFAULT_RENDERER_TYPE;
try {
UserPreferences userPreferences = UserSessionBean.getCurrentInstance().getUserPreferences();
editorRenderer = userPreferences.getPreference("ckEditor");
} catch (Exception ex) {
}
if (editorRenderer == null)
editorRenderer = DEFAULT_RENDERER_TYPE;
RenderKit renderKit = context.getRenderKit();
Renderer renderer = renderKit.getRenderer(getFamily(), editorRenderer);
if (renderer != null)
renderer.encodeEnd(context, this);
else
getRenderer(context).encodeEnd(context, this);
}
use of javax.faces.render.Renderer in project gdmatrix by gdmatrix.
the class DynamicForm method chooseBestRendererType.
// internal methods
protected String chooseBestRendererType(String rendererTypes) {
Form form = getForm();
String[] array = rendererTypes.split(",");
FacesContext facesContext = getFacesContext();
RenderKit renderKit = facesContext.getRenderKit();
String bestRendererType = null;
int bestSuitability = 0;
for (String rendererType : array) {
rendererType = rendererType.trim();
Renderer renderer = renderKit.getRenderer(FAMILY, rendererType);
int suitability;
if (renderer instanceof FormRenderer) {
FormRenderer formRenderer = (FormRenderer) renderer;
suitability = formRenderer.getSuitability(form, facesContext);
} else {
// default suitability
suitability = 1;
}
if (suitability > bestSuitability) {
bestSuitability = suitability;
bestRendererType = rendererType;
}
}
return bestRendererType;
}
Aggregations