if (viewId == null)
{
viewId = Pages.getViewId(getFacesContext());
}
ViewUrlBuilder url = new ViewUrlBuilder(viewId, getFragment(), !isPortletRequest(getFacesContext()));
Set<String> usedParameters = new HashSet<String>();
for (Object child : getChildren())
{
if (child instanceof UIParameter)
{
usedParameters.add(((UIParameter) child).getName());
url.addParameter((UIParameter) child);
}
}
if (viewId != null && isIncludePageParams())
{
Map<String, Object> pageParameters = Pages.instance().getStringValuesFromModel(context, viewId, usedParameters);
for (Map.Entry<String, Object> me : pageParameters.entrySet())
{
UIParameter uip = new UIParameter();
uip.setName(me.getKey());
uip.setValue(me.getValue());
url.addParameter(uip);
}
}
if (getActionExpression() != null)
{
UIAction uiAction = new UIAction();
uiAction.setAction(getActionExpression().getExpressionString());
url.addParameter(uiAction);
}
PropagationType propagationType = PropagationType.valueOf(getPropagation().toUpperCase());
if (propagationType == PropagationType.DEFAULT || propagationType == PropagationType.JOIN ||
propagationType == PropagationType.NESTED || propagationType == PropagationType.END)
{
UIConversationId uiConversationId = UIConversationId.newInstance();
uiConversationId.setViewId(viewId);
url.addParameter(uiConversationId);
}
if (propagationType == PropagationType.JOIN || propagationType == PropagationType.NESTED ||
propagationType == PropagationType.BEGIN || propagationType == PropagationType.END)
{
UIConversationPropagation uiPropagation = UIConversationPropagation.newInstance();
uiPropagation.setType(getPropagation());
uiPropagation.setPageflow(getPageflow());
url.addParameter(uiPropagation);
}
if (getConversationName() != null)
{
UIConversationName name = UIConversationName.newInstance();
name.setValue(getConversationName());
url.addParameter(name);
}
ValueExpression taskInstanceValueExpression = getValueExpression("taskInstance");
if (taskInstanceValueExpression != null)
{
UITaskId uiTaskId = UITaskId.newInstance();
uiTaskId.setValueExpression("taskInstance", taskInstanceValueExpression);
url.addParameter(uiTaskId);
}
if (!usedParameters.contains("dataModelSelection"))
{
UISelection uiSelection = getSelection();
if (uiSelection != null)
{
url.addParameter(uiSelection);
}
}
encodedUrl = url.getEncodedUrl();
return encodedUrl;
}