use of com.revolsys.ui.web.config.WebUiContext in project com.revolsys.open by revolsys.
the class ScriptsTag method doStartTag.
/**
* Process the start tag.
*
* @return SKIP_BODY
* @throws JspException If there was an exception processing the tag.
*/
@Override
public int doStartTag() throws JspException {
try {
final WebUiContext context = WebUiContext.get();
if (context != null) {
final Page page = context.getPage();
if (page != null) {
final JspWriter out = this.pageContext.getOut();
String contextPath = context.getContextPath();
if (contextPath.equals("/")) {
contextPath = "";
}
final Iterator scripts = page.getScripts().iterator();
while (scripts.hasNext()) {
final String script = (String) scripts.next();
out.print("<script type=\"text/javascript\" src=\"");
out.print(contextPath);
out.print(script);
out.println("\">\n</script>");
}
}
}
final SiteNodeController controller = (SiteNodeController) this.pageContext.findAttribute("rsWebController");
if (controller instanceof PageController) {
final PageController page = (PageController) controller;
writeScripts(page.getScripts());
}
} catch (final Throwable t) {
log.error(t.getMessage(), t);
}
return SKIP_BODY;
}
use of com.revolsys.ui.web.config.WebUiContext in project com.revolsys.open by revolsys.
the class IafServlet method processRequest.
/**
* Process the service request, uses the full path name of the request to
* finds the page definition. The component heirarchy, list of request
* processors and the menu tree from the config are used to handle the
* request. If a PageNotFoundException was thrown by any of the request
* processors a 404 response error code is set and no further processing is
* performed. If a RedirectException is thrown the response is redirected to
* the url from the exception.
*
* @param request the servlet request
* @param response the servlet response
* @exception ServletException if any unhandled exceptions occured during the
* processing of the request
* @exception IOException if there was a problem sending data to the client
* @see PageNotFoundException
* @see RedirectException
*/
public void processRequest(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
try {
String path = request.getServletPath();
final String pathInfo = request.getPathInfo();
if (pathInfo != null && !path.endsWith(pathInfo)) {
path += pathInfo;
}
boolean secure = false;
final String contextPath = request.getContextPath();
if (path.endsWith(".wp")) {
path = path.substring(0, path.length() - 3);
} else if (path.endsWith(".wps")) {
secure = true;
path = path.substring(0, path.length() - 4);
}
final Page page = this.applicationConfig.getPage(contextPath + path);
WebUiContext.set(new WebUiContext(this.applicationConfig, contextPath, page, request, response));
if (page.isSecure() && !secure) {
response.sendRedirect(page.getFullUrl());
return;
}
processArguments(page, request);
processAttributes(page, request);
request.setAttribute("niceConfig", this.applicationConfig);
request.setAttribute("nicePage", page);
final String menuName = request.getParameter("menuName");
request.setAttribute("menuSelected", menuName);
request.setAttribute("title", page.getTitle());
page.invokeActions(this.servletContext, request, response);
final Layout layout = page.getLayout();
if (layout != null) {
final String file = layout.getFile();
if (file != null && file.length() > 0) {
forward(file, request, response);
}
}
} catch (final FinishRequestException fre) {
// Do nothing as the actions have handled the request
return;
} catch (final AuthenticationException pne) {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
} catch (final PageNotFoundException pne) {
log.error(pne.getMessage(), pne);
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} catch (final RedirectException re) {
response.sendRedirect(response.encodeRedirectURL(re.getUrl()));
} catch (final Throwable t) {
log.error(t.getMessage(), t);
throw new ServletException(t);
}
}
use of com.revolsys.ui.web.config.WebUiContext in project com.revolsys.open by revolsys.
the class PageMenuView method processProperty.
@Override
public void processProperty(final String name, final Object value) {
final String stringValue = (String) value;
if (name.equals("menuName")) {
final WebUiContext context = WebUiContext.get();
setObject(context.getPage().getMenu(stringValue));
} else {
super.processProperty(name, value);
}
}
Aggregations