in empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/LinkTag.java [131:217]
public void encodeBegin(FacesContext context)
throws IOException
{
// add label and input components when the view is loaded for the first time
super.encodeBegin(context);
// begin
helper.encodeBegin();
if (isLinkDisabled())
{ // render disabled
ResponseWriter writer = context.getResponseWriter();
Object linkValue = getLinkValue(helper.hasColumn());
this.disabledTagName = writeStartElement(writer);
this.encodeLinkChildren = isEncodeLinkChildren(linkValue);
if (!encodeLinkChildren)
{ writer.write(StringUtils.toString(linkValue, ""));
writer.endElement(this.disabledTagName);
}
}
else
{ // Add component
HtmlOutcomeTargetLink linkComponent = null;
if (getChildCount() > 0)
{
UIComponent c = getChildren().get(0);
if (c instanceof HtmlOutcomeTargetLink)
{ // reuse
linkComponent = (HtmlOutcomeTargetLink)c;
helper.restoreComponentId(linkComponent);
// check image
if (linkComponent.getChildCount()>0)
{ // Check HtmlGraphicImage
int last = linkComponent.getChildCount()-1;
UIComponent lcc = linkComponent.getChildren().get(last);
if (lcc instanceof HtmlGraphicImage)
helper.restoreComponentId(lcc);
}
}
else
{ // Something's wrong here?
log.info("INFO: Unexpected child node for {}! Child item type is {}.", getClass().getName(), c.getClass().getName());
// Check facetComponent
UIPanel facetComponent = (UIPanel)getFacets().get(UIComponent.COMPOSITE_FACET_NAME);
if (facetComponent==null)
{
log.warn("WARN: component's facetComponent has not been set! Using Default (javax.faces.Panel).");
log.warn("Problem might be related to Mojarra's state context saving for dynamic components. See com.sun.faces.context.StateContext.java:AddRemoveListener");
facetComponent = (UIPanel)context.getApplication().createComponent("javax.faces.Panel");
facetComponent.setRendererType("javax.faces.Group");
getFacets().put(UIComponent.COMPOSITE_FACET_NAME, facetComponent);
}
}
}
if (linkComponent == null)
{ try {
creatingComponents = true;
linkComponent = createOutcomeTargetLink(context);
this.getChildren().add(0, linkComponent);
helper.saveComponentId(linkComponent);
// encode image
String imagePath = helper.getTagAttributeString("image");
if (StringUtils.isNotEmpty(imagePath))
{ // Create image
HtmlGraphicImage img = encodeImage(context, linkComponent, imagePath);
linkComponent.getChildren().add(img);
helper.saveComponentId(linkComponent);
}
// done
} finally {
creatingComponents = false;
}
}
// set params
setLinkProperties(linkComponent);
addOrSetParams(linkComponent);
// encode link
this.encodeLinkChildren = isEncodeLinkChildren(linkComponent.getChildCount()>0 ? null : linkComponent.getValue());
if (this.encodeLinkChildren)
linkComponent.encodeBegin(context);
else
{ // default rendering (no children)
linkComponent.setRendered(true);
encodeLinkComponent(context, linkComponent);
linkComponent.setRendered(false); // Don't render twice!
}
}
}