use of com.revolsys.ui.web.config.WebUiContext in project com.revolsys.open by revolsys.
the class MenuView method processProperty.
@Override
public void processProperty(final String name, final Object value) {
final String stringValue = (String) value;
if (name.equals("cssClass")) {
this.cssClass = value.toString();
} else if (name.equals("numLevels")) {
this.numLevels = Integer.parseInt(stringValue);
} else if (name.equals("menuName")) {
final WebUiContext context = WebUiContext.get();
setObject(context.getMenu(stringValue));
if (getObject() == null) {
throw new IllegalArgumentException("Menu " + value + " does not exist");
}
} else if (name.equals("showRoot")) {
this.showRoot = Boolean.valueOf(stringValue).booleanValue();
}
}
use of com.revolsys.ui.web.config.WebUiContext in project com.revolsys.open by revolsys.
the class OnLoadTag method doStartTag.
/**
* Process the start tag.
*
* @return SKIP_BODY
*/
@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();
final Iterator onLoads = page.getOnLoads().iterator();
out.print("onload=\"");
while (onLoads.hasNext()) {
final String onLoad = (String) onLoads.next();
out.print(onLoad);
out.print("; ");
}
out.print("\"");
}
}
return SKIP_BODY;
} catch (final Throwable t) {
throw new JspTagException(t);
}
}
use of com.revolsys.ui.web.config.WebUiContext in project com.revolsys.open by revolsys.
the class StylesTag 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 Collection styles = page.getStyles();
String contextPath = context.getContextPath();
if (contextPath.equals("/")) {
contextPath = "";
}
final JspWriter out = this.pageContext.getOut();
final Iterator styleIter = styles.iterator();
while (styleIter.hasNext()) {
final String style = (String) styleIter.next();
out.print("<link rel=\"stylesheet\" href=\"");
out.print(style);
out.println("\" type=\"text/css\" />");
}
}
}
final SiteNodeController controller = (SiteNodeController) this.pageContext.findAttribute("rsWebController");
if (controller instanceof PageController) {
final PageController page = (PageController) controller;
serializeElements(page.getStyles());
}
return SKIP_BODY;
} catch (final Throwable t) {
log.error(t.getMessage(), t);
throw new JspTagException(t.getMessage(), t);
}
}
use of com.revolsys.ui.web.config.WebUiContext in project com.revolsys.open by revolsys.
the class IafServletFilter method doFilter.
@Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException {
try {
final HttpServletRequest httpRequest = (HttpServletRequest) request;
final HttpServletResponse httpResponse = (HttpServletResponse) response;
final String contextPath = httpRequest.getContextPath();
WebUiContext.set(new WebUiContext(this.rsWebUiConfig, contextPath, null, httpRequest, httpResponse));
request.setAttribute("niceConfig", this.rsWebUiConfig);
chain.doFilter(request, response);
} finally {
WebUiContext.set(null);
}
}
use of com.revolsys.ui.web.config.WebUiContext in project com.revolsys.open by revolsys.
the class WebUiFilter method doFilter.
public void doFilter(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws IOException, ServletException {
if (this.rsWebUiConfig != null) {
try {
final HttpServletRequest httpRequest = request;
final HttpServletResponse httpResponse = response;
final String contextPath = httpRequest.getContextPath();
Page page;
try {
page = this.rsWebUiConfig.getPage(request.getServletPath() + request.getPathInfo());
} catch (final PageNotFoundException e) {
page = new Page(null, null, "/", false);
}
WebUiContext.set(new WebUiContext(this.rsWebUiConfig, contextPath, page, httpRequest, httpResponse));
request.setAttribute("rsWebUiConfig", this.rsWebUiConfig);
chain.doFilter(request, response);
} finally {
WebUiContext.set(null);
}
} else {
try {
final String path = request.getServletPath();
final String serverName = request.getServerName();
if (this.applicationContext.containsBean(serverName)) {
this.site = (Site) this.applicationContext.getBean(serverName);
} else {
LOG.info("using default site");
this.site = (Site) this.applicationContext.getBean("default");
}
if (this.site != null) {
final SiteNodeController controller = this.site.getController(path);
LOG.debug(path + "=" + controller);
request.setAttribute("site", this.site);
request.setAttribute("rsWebController", controller);
if (controller != null) {
controller.process(this.servletContext, request, response);
return;
}
}
chain.doFilter(request, response);
} catch (final RuntimeException e) {
LOG.error(e.getMessage(), e);
throw e;
} catch (final ServletException e) {
LOG.error(e.getMessage(), e);
throw e;
}
}
}
Aggregations