parent = parent.getParent();
}
UIForm nestingForm = null;
String formName;
DummyFormResponseWriter dummyFormResponseWriter;
if (parent != null)
{
//link is nested inside a form
nestingForm = (UIForm)parent;
formName = nestingForm.getClientId(facesContext);
dummyFormResponseWriter = null;
}
else
{
//not nested in form, we must add a dummy form at the end of the document
formName = DummyFormUtils.DUMMY_FORM_NAME;
dummyFormResponseWriter = DummyFormUtils.getDummyFormResponseWriter(facesContext);
dummyFormResponseWriter.setWriteDummyForm(true);
}
StringBuffer onClick = new StringBuffer();
String commandOnclick;
if (component instanceof HtmlCommandLink)
{
commandOnclick = ((HtmlCommandLink)component).getOnclick();
}
else
{
commandOnclick = (String)component.getAttributes().get(HTML.ONCLICK_ATTR);
}
if (commandOnclick != null)
{
onClick.append(commandOnclick);
onClick.append(';');
}
//call the clear_<formName> method
onClick.append(HtmlRendererUtils.getClearHiddenCommandFormParamsFunctionName(formName)).append("();");
String jsForm = "document.forms['" + formName + "']";
if (MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isAutoScroll())
{
JavascriptUtils.appendAutoScrollAssignment(onClick, formName);
}
//add id parameter for decode
String hiddenFieldName = HtmlRendererUtils.getHiddenCommandLinkFieldName(formName);
onClick.append(jsForm);
onClick.append(".elements['").append(hiddenFieldName).append("']");
onClick.append(".value='").append(clientId).append("';");
if (nestingForm != null)
{
HtmlFormRendererBase.addHiddenCommandParameter(nestingForm, hiddenFieldName);
}
else
{
dummyFormResponseWriter.addDummyFormParameter(hiddenFieldName);
}
//add child parameters
for (Iterator it = component.getChildren().iterator(); it.hasNext(); )
{