Java Code Examples for javax.faces.application.Application#createValueBinding()

The following examples show how to use javax.faces.application.Application#createValueBinding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TagUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Set a ValueBinding on a component - used by tags setProperties() method.
 */
public static void setValueBinding(UIComponent component, String name, String value)
{
    FacesContext context = FacesContext.getCurrentInstance();
    Application app = context.getApplication();
    ValueBinding vb = app.createValueBinding(value);
    component.setValueBinding(name, vb);
}
 
Example 2
Source File: RichTextEditArea.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static void setValueBinding(UIComponent component, String attributeName,
        String attributeValue)
{
  FacesContext context = FacesContext.getCurrentInstance();
  Application app = context.getApplication();
  ValueBinding vb = app.createValueBinding(attributeValue);
  component.setValueBinding(attributeName, vb);
}
 
Example 3
Source File: CustomSelectOneRadioTag.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public ValueBinding getValueBinding(String valueRef) {
	ApplicationFactory af =
		(ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
	Application a = af.getApplication();

	return (a.createValueBinding(valueRef));
}
 
Example 4
Source File: TagUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Set a ValueBinding on a component - used by tags setProperties() method.
 */
public static void setValueBinding(UIComponent component, String name, String value)
{
    FacesContext context = FacesContext.getCurrentInstance();
    Application app = context.getApplication();
    ValueBinding vb = app.createValueBinding(value);
    component.setValueBinding(name, vb);
}
 
Example 5
Source File: TagUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Set a ValueBinding on a component - used by tags setProperties() method.
 */
public static void setValueBinding(UIComponent component, String name, String value)
{
    FacesContext context = FacesContext.getCurrentInstance();
    Application app = context.getApplication();
    ValueBinding vb = app.createValueBinding(value);
    component.setValueBinding(name, vb);
}
 
Example 6
Source File: TagUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static void setValueBinding(UIComponent component,
  String attributeName,
  String attributeValue)
{
  FacesContext context = FacesContext.getCurrentInstance();
  Application app = context.getApplication();
  ValueBinding vb = app.createValueBinding(attributeValue);
  component.setValueBinding(attributeName, vb);
}
 
Example 7
Source File: SyllabusShowAreaTag.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static void setValueBinding(UIComponent component,
    String attributeName, String attributeValue)
{
  FacesContext context = FacesContext.getCurrentInstance();
  Application app = context.getApplication();
  ValueBinding vb = app.createValueBinding(attributeValue);
  component.setValueBinding(attributeName, vb);
}
 
Example 8
Source File: SyllabusIfTag.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static void setValueBinding(UIComponent component,
    String attributeName, String attributeValue)
{
  FacesContext context = FacesContext.getCurrentInstance();
  Application app = context.getApplication();
  ValueBinding vb = app.createValueBinding(attributeValue);
  component.setValueBinding(attributeName, vb);
}
 
Example 9
Source File: SyllabusShowAreaTag.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static void setValueBinding(UIComponent component,
    String attributeName, String attributeValue)
{
  FacesContext context = FacesContext.getCurrentInstance();
  Application app = context.getApplication();
  ValueBinding vb = app.createValueBinding(attributeValue);
  component.setValueBinding(attributeName, vb);
}
 
Example 10
Source File: TagUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static void setValueBinding(UIComponent component,
  String attributeName,
  String attributeValue)
{
  FacesContext context = FacesContext.getCurrentInstance();
  Application app = context.getApplication();
  ValueBinding vb = app.createValueBinding(attributeValue);
  component.setValueBinding(attributeName, vb);
}
 
Example 11
Source File: ShowAreaTag.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static void setValueBinding(UIComponent component,
    String attributeName, String attributeValue)
{
  FacesContext context = FacesContext.getCurrentInstance();
  Application app = context.getApplication();
  ValueBinding vb = app.createValueBinding(attributeValue);
  component.setValueBinding(attributeName, vb);
}
 
Example 12
Source File: Tags.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static void setValueBinding(UIComponent component,
		String attributeName, String attributeValue) {
	FacesContext context = FacesContext.getCurrentInstance();
	Application app = context.getApplication();
	ValueBinding vb = app.createValueBinding(attributeValue);
	component.setValueBinding(attributeName, vb);
}
 
Example 13
Source File: SyllabusIfNotTag.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static void setValueBinding(UIComponent component,
    String attributeName, String attributeValue)
{
  FacesContext context = FacesContext.getCurrentInstance();
  Application app = context.getApplication();
  ValueBinding vb = app.createValueBinding(attributeValue);
  component.setValueBinding(attributeName, vb);
}
 
Example 14
Source File: Tags.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static void setValueBinding(UIComponent component, String attributeName,
      String attributeValue) {
   FacesContext context = FacesContext.getCurrentInstance();
   Application app = context.getApplication();
   ValueBinding vb = app.createValueBinding(attributeValue);
   component.setValueBinding(attributeName, vb);
}
 
Example 15
Source File: CustomSelectOneRadioTag.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public ValueBinding getValueBinding(String valueRef) {
	ApplicationFactory af =
		(ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
	Application a = af.getApplication();

	return (a.createValueBinding(valueRef));
}
 
Example 16
Source File: TagUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Set a ValueBinding on a component - used by tags setProperties() method.
 */
public static void setValueBinding(UIComponent component, String name, String value)
{
    FacesContext context = FacesContext.getCurrentInstance();
    Application app = context.getApplication();
    ValueBinding vb = app.createValueBinding(value);
    component.setValueBinding(name, vb);
}
 
Example 17
Source File: Tags.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static void setValueBinding(UIComponent component,
		String attributeName, String attributeValue) {
	FacesContext context = FacesContext.getCurrentInstance();
	Application app = context.getApplication();
	ValueBinding vb = app.createValueBinding(attributeValue);
	component.setValueBinding(attributeName, vb);
}
 
Example 18
Source File: AjaxPhaseListener.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void afterPhase(PhaseEvent event) {
	FacesContext context = FacesContext.getCurrentInstance();
	Application app = context.getApplication();
	ValueBinding binding = app.createValueBinding("#{ForumTool}");
	DiscussionForumTool forumTool = (DiscussionForumTool) binding
			.getValue(context);
	Map requestParams = context.getExternalContext()
			.getRequestParameterMap();

	String action = (String) requestParams.get("action");
	String messageId = (String) requestParams.get("messageId");
	String topicId = (String) requestParams.get("topicId");
	String ajax = (String) requestParams.get("ajax");

	HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();
	if ("true".equals(ajax)) {
		try {
			ServletOutputStream out = response.getOutputStream();
			response.setHeader("Pragma", "No-Cache");
			response.setHeader("Cache-Control",
					"no-cache,no-store,max-age=0");
			response.setDateHeader("Expires", 1);
			if (action == null) {
				out.println("FAIL");
			} else if ("markMessageAsRead".equals(action)) {
				// Ajax call to mark messages as read for user
				if (messageId != null && topicId != null) {
					if (!forumTool.isMessageReadForUser(Long.valueOf(topicId),
							Long.valueOf(messageId))) {
						forumTool.markMessageReadForUser(Long.valueOf(topicId),
								Long.valueOf(messageId), true);
						out.println("SUCCESS");
					} else {
						// also output success in case message is read, but
						// page rendered mail icon (old state)
						out.println("SUCCESS");
					}
				}
			}
			out.flush();
		} catch (Exception ee) {
			log.error(ee.getMessage(), ee);
		}
		context.responseComplete();
	}
	;
}
 
Example 19
Source File: HelpFrameSetRender.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/** 
 * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
 */
public void encodeBegin(FacesContext context, UIComponent component)
    throws IOException
{
  ResponseWriter writer = context.getResponseWriter();
  String helpWindowTitle = (String) component.getAttributes().get(
      "helpWindowTitle");
  String searchToolUrl = (String) component.getAttributes().get(
      "searchToolUrl");
  String tocToolUrl = (String) component.getAttributes().get("tocToolUrl");        
  
  String helpParameter = ((HttpServletRequest) context.getExternalContext()
      .getRequest()).getParameter("help");

  if (helpParameter != null) {
   Pattern p = Pattern.compile(HELP_DOC_REGEXP);
   Matcher m = p.matcher(helpParameter);
   
   if (!m.matches()) {
   	helpParameter = "unknown";
   }
  }
  String welcomepage = getWelcomePage(context);

  tocToolUrl = tocToolUrl + "?help=" + helpParameter;

  EventTrackingService.post(EventTrackingService.newEvent("help.access", helpParameter, false));

  helpWindowTitle = ServerConfigurationService.getString("ui.service", "Sakai") + " " + component.getAttributes().get("helpWindowTitle");
  
  writer.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">\n");
  writer.write("<html><head><title>" + helpWindowTitle + "</title></head>\n");
  writer.write("<FRAMESET cols=\"20%, 80%\"><FRAMESET rows=\"150, 450\">");
  writer.write("<FRAME src=\"" + searchToolUrl + "\" name=\"search\" title=\"Search\">");
  writer.write("<FRAME src=\"" + tocToolUrl + "\" name=\"toc\" title=\"Table of Contents\">");
  writer.write("</FRAMESET>\n");
  
  Application app = context.getApplication();
  ValueBinding binding = app.createValueBinding("#{Components['org.sakaiproject.api.app.help.HelpManager']}");
  HelpManager manager  = (HelpManager) binding.getValue(context);    
                
  if(manager.getWelcomePage() == null) {
      if (welcomepage == DEFAULT_WELCOME_PAGE) {
    	  writer.write("<FRAME src=\"content.hlp?docId=" + welcomepage + "\" name=\"content\" title=\"Help Content\">");
      } else {
        writer.write("<FRAME src=\"" + welcomepage + "\" name=\"content\" title=\"Help Content\">");
      }

  }
  else {
    writer.write("<FRAME src=\"content.hlp?docId=" + manager.getWelcomePage() + "\" name=\"content\" title=\"Help Content\">");
  }
                                      
  writer.write("</FRAMESET></html>\n");
}
 
Example 20
Source File: HelpFrameSetRender.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/** 
 * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
 */
public void encodeBegin(FacesContext context, UIComponent component)
    throws IOException
{
  ResponseWriter writer = context.getResponseWriter();
  String helpWindowTitle = (String) component.getAttributes().get(
      "helpWindowTitle");
  String searchToolUrl = (String) component.getAttributes().get(
      "searchToolUrl");
  String tocToolUrl = (String) component.getAttributes().get("tocToolUrl");        
  
  String helpParameter = ((HttpServletRequest) context.getExternalContext()
      .getRequest()).getParameter("help");

  if (helpParameter != null) {
   Pattern p = Pattern.compile(HELP_DOC_REGEXP);
   Matcher m = p.matcher(helpParameter);
   
   if (!m.matches()) {
   	helpParameter = "unknown";
   }
  }
  String welcomepage = getWelcomePage(context);

  tocToolUrl = tocToolUrl + "?help=" + helpParameter;

  EventTrackingService.post(EventTrackingService.newEvent("help.access", helpParameter, false));

  helpWindowTitle = ServerConfigurationService.getString("ui.service", "Sakai") + " " + component.getAttributes().get("helpWindowTitle");
  
  writer.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">\n");
  writer.write("<html><head><title>" + helpWindowTitle + "</title></head>\n");
  writer.write("<FRAMESET cols=\"20%, 80%\"><FRAMESET rows=\"150, 450\">");
  writer.write("<FRAME src=\"" + searchToolUrl + "\" name=\"search\" title=\"Search\">");
  writer.write("<FRAME src=\"" + tocToolUrl + "\" name=\"toc\" title=\"Table of Contents\">");
  writer.write("</FRAMESET>\n");
  
  Application app = context.getApplication();
  ValueBinding binding = app.createValueBinding("#{Components['org.sakaiproject.api.app.help.HelpManager']}");
  HelpManager manager  = (HelpManager) binding.getValue(context);    
                
  if(manager.getWelcomePage() == null) {
      if (welcomepage == DEFAULT_WELCOME_PAGE) {
    	  writer.write("<FRAME src=\"content.hlp?docId=" + welcomepage + "\" name=\"content\" title=\"Help Content\">");
      } else {
        writer.write("<FRAME src=\"" + welcomepage + "\" name=\"content\" title=\"Help Content\">");
      }

  }
  else {
    writer.write("<FRAME src=\"content.hlp?docId=" + manager.getWelcomePage() + "\" name=\"content\" title=\"Help Content\">");
  }
                                      
  writer.write("</FRAMESET></html>\n");
}