PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest);
PortletResponse portletResponse = (PortletResponse) externalContext.getResponse();
HttpServletResponse httpServletResponse = PortalUtil.getHttpServletResponse(portletResponse);
ELContext elContext = liferayFacesContext.getELContext();
StringJspWriter stringJspWriter = new StringJspWriter();
PageContextAdapter pageContextAdapter = new PageContextAdapter(httpServletRequest, httpServletResponse,
elContext, stringJspWriter);
// Invoke the Liferay Tag class directly (rather than using the tag from a JSP).
PermissionsURLTag permissionsURLTag = new PermissionsURLTag();
permissionsURLTag.setPageContext(pageContextAdapter);
permissionsURLTag.setModelResource(MODEL);
permissionsURLTag.setModelResourceDescription(getName());
permissionsURLTag.setRedirect("false");
permissionsURLTag.setResourceGroupId(scopeGroupId);
permissionsURLTag.setResourcePrimKey(String.valueOf(getGuestbookId()));
// Set var to null if you want the tag to write out the url
permissionsURLTag.setVar(null);
try {
permissionsURLTag.doStartTag();
permissionsURLTag.doEndTag();
permissionsUrl = stringJspWriter.toString();
}
catch (Exception e) {
logger.error(e);
}