// Theorically this method should always return null, but it is known
// than in some cases (portlet) when the state manager is different from
// the default one, transient components are saved on the component tree.
// Really the error is on the jsf portlet bridge implementation used, but
// do this does not cause any side effect.
HtmlCommandLink link = (HtmlCommandLink) scroller.findComponent(scroller.getId() + id);
if (link == null)
{
// See Jira Issue TOMAHAWK-117 http://issues.apache.org/jira/browse/TOMAHAWK-117
// and http://issues.apache.org/jira/browse/MYFACES-1809
link = new org.apache.myfaces.component.html.ext.HtmlCommandLink();
//Copy all client behaviors
for (Map.Entry<String,List<ClientBehavior>> entry : scroller.getClientBehaviors().entrySet())
{
List<ClientBehavior> list = entry.getValue();
if (list != null && !list.isEmpty())
{
for (ClientBehavior cb : list)
{
link.addClientBehavior(entry.getKey(), cb);
}
}
}
link.setId(scroller.getId() + id);
link.setTransient(true);
UIParameter parameter = (UIParameter) application
.createComponent(UIParameter.COMPONENT_TYPE);
parameter.setId(scroller.getId() + id + "_param");
parameter.setTransient(true);
parameter.setName(scroller.getClientId(facesContext));
parameter.setValue(id);
List children = link.getChildren();
children.add(parameter);
if (text != null)
{
HtmlOutputText uiText = (HtmlOutputText) application
.createComponent(HtmlOutputText.COMPONENT_TYPE);
uiText.setId(scroller.getId() + id + "_text");
uiText.setTransient(true);
uiText.setValue(text);
children.add(uiText);
}
scroller.getChildren().add(link);
}
else
{
UIOutput uiText = (UIOutput) link.findComponent(scroller.getId() + id + "_text");
if (uiText != null)
{
//Update text value
uiText.setValue(text);
}