Java Code Examples for javax.faces.component.UIComponent#getId()

The following examples show how to use javax.faces.component.UIComponent#getId() . 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: HideDivisionRenderer.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * <p>Faces render output method to output script tag.</p>
   * <p>Method Generator: org.sakaiproject.tool.assessment.devtoolsRenderMaker</p>
 *
 *  @param context   <code>FacesContext</code> for the current request
 *  @param component <code>UIComponent</code> being rendered
 *
 * @throws IOException if an input/output error occurs
 */
public void encodeEnd(FacesContext context, UIComponent component) throws
    IOException {
  if (!component.isRendered()) {
    return;
  }

  ResponseWriter writer = context.getResponseWriter();

  String jsfId = (String) RendererUtil.getAttribute(context, component, "id");
  String id = jsfId;

  if (component.getId() != null &&
    !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
  {
    id = component.getClientId(context);
  }

  writer.write("</div>");

  writer.write("<script type=\"text/javascript\">");
  writer.write("  showHideDiv('" + id +
        "', '" +  RESOURCE_PATH + "');");
  writer.write("</script>");
}
 
Example 2
Source File: HideDivisionRenderer.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public void encodeEnd(FacesContext context, UIComponent component) throws
  IOException {
    if (!component.isRendered()) {
      return;
    }

    ResponseWriter writer = context.getResponseWriter();

    String jsfId = (String) RendererUtil.getAttribute(context, component, "id");
    String id = jsfId;

    if (component.getId() != null &&
        !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
    {
      id = component.getClientId(context);
    }

    writer.write("</div>");

//    writer.write("<script type=\"text/javascript\">");
//    writer.write("  showHideDiv('" + id +
//        "', '" +  RESOURCE_PATH + "');");
//    writer.write("</script>");
  }
 
Example 3
Source File: DataTableRenderer.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
private void resetClientIdCacheRecursively(UIComponent c) {
	String id = c.getId();
	if (null != id) {
		c.setId(id); // this strange operation clears the cache of the clientId
	}
	Iterator<UIComponent> children = c.getFacetsAndChildren();
	if (children != null) {
		while (children.hasNext()) {
			UIComponent kid = children.next();
			resetClientIdCacheRecursively(kid);
		}
	}
}
 
Example 4
Source File: MessageListener.java    From development with Apache License 2.0 5 votes vote down vote up
/**
 * Tries to get the id of a parent section if existing.
 * 
 * @param uiComponent
 *            the component to check the parents for
 * @return the id of the section if found or <code>null</code>
 */
private String getSectionId(UIComponent uiComponent) {
    UIComponent parent = uiComponent.getParent();
    if (parent instanceof UIViewRoot) {
        return null;
    }
    if (parent instanceof UITogglePanel) {
        return parent.getId();
    }
    return getSectionId(parent);
}
 
Example 5
Source File: ExpressionResolverUtilities.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
public static String determineQualifiedId(UIComponent component) {
	String qualifiedId = "";
	if (component instanceof NamingContainer) 
		return "";
	
	while (component != null && (!(component instanceof UIViewRoot)) && (!(component instanceof NamingContainer))) {
		component = component.getParent();
		if (component instanceof NamingContainer)
			qualifiedId = component.getId() + ":" + qualifiedId;
	}
	return ":" + qualifiedId;
}
 
Example 6
Source File: HideDivisionRenderer.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void encodeBegin(FacesContext context, UIComponent component)
throws IOException {

	if (!component.isRendered()) {
		return;
	}

	ResponseWriter writer = context.getResponseWriter();
	String jsfId = (String) RendererUtil.getAttribute(context, component, "id");
	String id = jsfId;

	if (component.getId() != null &&
			!component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
	{
		id = component.getClientId(context);
	}

	String title = (String) RendererUtil.getAttribute(context, component, "title");
	Object tmpFoldStr = RendererUtil.getAttribute(context, component, "hideByDefault");
	String key = (String)RendererUtil.getAttribute(context, component, "key");
	
	writer.write("<fieldset>");
	writer.write("<legend>");
	writer.write("<a role='button' data-toggle='collapse' aria-expanded='true' aria-target='" + id + "' href='#" + id + "' data-target=\"[id='" + id + "']\">" + title + "</a>");
	writer.write("</legend>");

	writer.write("<div class='collapse in' " +
		" id=\"" + id + "\">");
}
 
Example 7
Source File: AbstractRestService.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void writeId(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
    // only write valid user defined ids
    String id = component.getId();
    if (id != null && !id.startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
        writer.writeAttribute("id", component.getClientId(context), "id"); // $NON-NLS-1$ $NON-NLS-2$
    }
}
 
Example 8
Source File: TimerBarRenderer.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
* <p>Faces render output method .</p>
* <p>Method Generator: org.sakaiproject.tool.assessment.devtools.RenderMaker</p>
*
*  @param context   <code>FacesContext</code> for the current request
*  @param component <code>UIComponent</code> being rendered
*
* @throws IOException if an input/output error occurs
*/
 public void encodeEnd(FacesContext context, UIComponent component)
   throws IOException {

    if (!component.isRendered())
    {
      return;
     }

     ResponseWriter writer = context.getResponseWriter();

     String clientId = null;

     if (component.getId() != null &&
       !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
     {
       clientId = component.getClientId(context);
     }

     if (clientId != null)
     {
       writer.startElement("span", component);
       writer.writeAttribute("id", clientId, "id");
     }

      String contextPath = context.getExternalContext().getRequestContextPath();
      writer.write("\n<script type=\"text/javascript\" src=\"" +
        contextPath + SCRIPT_PATH + "timerbar.js\"></script>");
      writer.write("\n");

     if (clientId != null)
       {
       writer.endElement("span");
     }
 }
 
Example 9
Source File: TabRepeat.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
private void restoreChildState(FacesContext faces, UIComponent c) {
	// reset id
	String id = c.getId();
	c.setId(id);

	// hack
	if (c instanceof EditableValueHolder) {
		EditableValueHolder evh = (EditableValueHolder) c;
		String clientId = c.getClientId(faces);
		SavedState ss = this.getChildState().get(clientId);
		if (ss != null) {
			ss.apply(evh);
		} else {
			String childId = clientId.substring(initialClientId.length() + 1);
			childId = childId.substring(childId.indexOf(getSeparatorChar(faces)) + 1);
			childId = initialClientId + getSeparatorChar(faces) + childId;
			if (initialChildState.containsKey(childId)) {
				SavedState initialState = initialChildState.get(childId);
				initialState.apply(evh);
			} else {
				NullState.apply(evh);
			}
		}
	}

	// continue hack
	Iterator itr = c.getFacetsAndChildren();
	while (itr.hasNext()) {
		restoreChildState(faces, (UIComponent) itr.next());
	}
}
 
Example 10
Source File: ToolBarRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * We put all our processing in the encodeChildren method
 * @param context
 * @param component
 * @throws IOException
 */
public void encodeChildren(FacesContext context, UIComponent component) throws IOException
{
    if (!component.isRendered())
    {
        return;
    }

    String clientId = null;

    if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
    {
        clientId = component.getClientId(context);
    }

    ResponseWriter writer = context.getResponseWriter();

    if (clientId != null)
    {
        writer.startElement("ul", component);
        //writer.append(" class=\"jsfToolbar\" "); // we don't seem to get here
    }

    @SuppressWarnings("unchecked")
    List<UIComponent> children = component.getChildren();

    // this is a special separator attribute, not supported by UIData
    String separator = (String) RendererUtil.getAttribute(context, component, "separator");
    if (separator == null)
    {
        separator = "";
    }

    boolean first = true;
    boolean foundCurrent = false;
    for( UIComponent child : children )
    {
        // should instead leave the span open, and the item should then add class and aria attributes
        // depending on the item is (disabled or not) and then close
        if (child.isRendered()) {
            if (!first)
            {
                writer.write("<li>");
            }
            else
            {
                writer.write("<li class=\"firstToolBarItem\">");
            }
            // SAK-23062 improve JSF options menu
            boolean current = false;
            if (!foundCurrent) {
                // check for the "current" attribute on the custom tag, mark that item as current if it set to true
                boolean hasCurrentIndicated = (child.getAttributes().get("current") != null); // NOTE: child.getAttributes().containsKey("current") will NOT work here
                current = (hasCurrentIndicated && ((Boolean)child.getAttributes().get("current")));
                /* this breaks too many other things
                 * if (!hasCurrentIndicated && !"javax.faces.Link".equals(child.getRendererType())) {
                 * // basically - if it is not a link, it is probably the current item
                 * current = true;
                 * }
                 */
            }
            if (current) {
                foundCurrent = true;
                writer.write("<span class=\"current\">");
            } else {
                writer.write("<span>");
            }
            RendererUtil.encodeRecursive(context, child);
            writer.write("</span></li> ");
            first = false;
        }
    }
    if (clientId != null)
    {
         writer.endElement("ul");
    }
}
 
Example 11
Source File: OutputDateRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
* <p>Faces render output method .</p>
* <p>Method Generator: org.sakaiproject.tool.assessment.devtoolsRenderMaker</p>
*
*  @param context   <code>FacesContext</code> for the current request
*  @param component <code>UIComponent</code> being rendered
*
* @throws IOException if an input/output error occurs
*/

public void encodeBegin(FacesContext context, UIComponent component) throws
  IOException
{
  if (!component.isRendered())
  {
    return;
  }

  ResponseWriter writer = context.getResponseWriter();

  // this is a date object representing our date
  // this is a debug line, we are losing our date
  Date date = ((Date) RendererUtil.getDefaultedAttribute(
    context, component, "value", new Date()));
  // this is the formatted output representation of the date
  String dateStr = "";
  String formatStr = getFormatString(context, component);
  dateStr = format(date, formatStr);


  String clientId = null;

  if (component.getId() != null &&
    !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
  {
    clientId = component.getClientId(context);
  }

  if (clientId != null)
  {
    writer.startElement("span", component);
    writer.writeAttribute("id", clientId, "id");
  }
  writer.write(dateStr);
  if (clientId != null)
  {
    writer.endElement("span");
  }

}
 
Example 12
Source File: ProgressBarRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
* <p>Faces render output method .</p>
*  @param context   <code>FacesContext</code> for the current request
*  @param component <code>UIComponent</code> being rendered
*
* @throws IOException if an input/output error occurs
*/
 public void encodeEnd(FacesContext context, UIComponent component)
   throws IOException {

    if (!component.isRendered())
    {
      return;
     }

     ResponseWriter writer = context.getResponseWriter();

     String clientId = null;

     if (component.getId() != null &&
       !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
     {
       clientId = component.getClientId(context);
     }

     if (clientId != null)
     {
       writer.startElement("span", component);
       writer.writeAttribute("id", clientId, "id");
     }

     Map attrMap = component.getAttributes();

     writer.write("\n");
     writer.write("\n<script language=\"javascript\">");
     writer.write("\n// Timer Bar - Version 1.0");
     writer.write(
         "\n// Based on Script by Brian Gosselin of http://scriptasylum.com");
     writer.write(
         "\n  var loadedcolor='blue' ;            // PROGRESS BAR COLOR");
     writer.write(
         "\n  var unloadedcolor='white';         // COLOR OF UNLOADED AREA");
     writer.write(
         "\n  var bordercolor='white';            // COLOR OF THE BORDER");
     writer.write("\n  var barheight = 45; // HEIGHT OF PROGRESS BAR IN PIXELS");
     writer.write("\n  var barwidth = 300; // WIDTH OF THE BAR IN PIXELS");
     writer.write("\n  var waitTime = " + attrMap.get("wait") +
                  "; // NUMBER OF SECONDS FOR PROGRESSBAR");
     writer.write("\n  var loaded = 0; // TENTHS OF A SECOND ELAPSED");
     writer.write(
         "\n// THE FUNCTION BELOW CONTAINS THE ACTION(S) TAKEN ONCE BAR REACHES 100.");
     writer.write("\n");
     writer.write("\n  var action = function()");
     writer.write("\n {");
     writer.write("\n }");
     writer.write("\n</script>");
     writer.write("\n<script language=\"javascript\" src=\"" +
          "/" + RESOURCE_PATH + "/" + SCRIPT_PATH + "\"></script>");
     writer.write("\n");

     if (clientId != null) {
       writer.endElement("span");
     }
 }
 
Example 13
Source File: ToolBarRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * We put all our processing in the encodeChildren method
 * @param context
 * @param component
 * @throws IOException
 */
public void encodeChildren(FacesContext context, UIComponent component) throws IOException
{
    if (!component.isRendered())
    {
        return;
    }

    String clientId = null;

    if (component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
    {
        clientId = component.getClientId(context);
    }

    ResponseWriter writer = context.getResponseWriter();

    if (clientId != null)
    {
        writer.startElement("ul", component);
        //writer.append(" class=\"jsfToolbar\" "); // we don't seem to get here
    }

    @SuppressWarnings("unchecked")
    List<UIComponent> children = component.getChildren();

    // this is a special separator attribute, not supported by UIData
    String separator = (String) RendererUtil.getAttribute(context, component, "separator");
    if (separator == null)
    {
        separator = "";
    }

    boolean first = true;
    boolean foundCurrent = false;
    for( UIComponent child : children )
    {
        // should instead leave the span open, and the item should then add class and aria attributes
        // depending on the item is (disabled or not) and then close
        if (child.isRendered()) {
            if (!first)
            {
                writer.write("<li>");
            }
            else
            {
                writer.write("<li class=\"firstToolBarItem\">");
            }
            // SAK-23062 improve JSF options menu
            boolean current = false;
            if (!foundCurrent) {
                // check for the "current" attribute on the custom tag, mark that item as current if it set to true
                boolean hasCurrentIndicated = (child.getAttributes().get("current") != null); // NOTE: child.getAttributes().containsKey("current") will NOT work here
                current = (hasCurrentIndicated && ((Boolean)child.getAttributes().get("current")));
                /* this breaks too many other things
                 * if (!hasCurrentIndicated && !"javax.faces.Link".equals(child.getRendererType())) {
                 * // basically - if it is not a link, it is probably the current item
                 * current = true;
                 * }
                 */
            }
            if (current) {
                foundCurrent = true;
                writer.write("<span class=\"current\">");
            } else {
                writer.write("<span>");
            }
            RendererUtil.encodeRecursive(context, child);
            writer.write("</span></li> ");
            first = false;
        }
    }
    if (clientId != null)
    {
         writer.endElement("ul");
    }
}
 
Example 14
Source File: OutputDateRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
* <p>Faces render output method .</p>
* <p>Method Generator: org.sakaiproject.tool.assessment.devtoolsRenderMaker</p>
*
*  @param context   <code>FacesContext</code> for the current request
*  @param component <code>UIComponent</code> being rendered
*
* @throws IOException if an input/output error occurs
*/

public void encodeBegin(FacesContext context, UIComponent component) throws
  IOException
{
  if (!component.isRendered())
  {
    return;
  }

  ResponseWriter writer = context.getResponseWriter();

  // this is a date object representing our date
  // this is a debug line, we are losing our date
  Date date = ((Date) RendererUtil.getDefaultedAttribute(
    context, component, "value", new Date()));
  // this is the formatted output representation of the date
  String dateStr = "";
  String formatStr = getFormatString(context, component);
  dateStr = format(date, formatStr);


  String clientId = null;

  if (component.getId() != null &&
    !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
  {
    clientId = component.getClientId(context);
  }

  if (clientId != null)
  {
    writer.startElement("span", component);
    writer.writeAttribute("id", clientId, "id");
  }
  writer.write(dateStr);
  if (clientId != null)
  {
    writer.endElement("span");
  }

}
 
Example 15
Source File: ColorPickerRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
  * <p>Faces render output method .</p>
  * <p>Method Generator: org.sakaiproject.tool.assessment.devtoolsRenderMaker</p>
  *
  *  @param context   <code>FacesContext</code> for the current request
  *  @param component <code>UIComponent</code> being rendered
  *
  * @throws IOException if an input/output error occurs
  */
 public void encodeEnd(FacesContext context,
   UIComponent component) throws IOException
 {
ResourceLoader rb= new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages");
   ResponseWriter writer = context.getResponseWriter();
   String contextPath = context.getExternalContext()
                        .getRequestContextPath();

   Object value = null;
   if (component instanceof UIInput)
   {
     value = ( (UIInput) component).getSubmittedValue();
   }
   if (value == null && component instanceof ValueHolder)
   {
     value = ( (ValueHolder) component).getValue();
   }
   String valString = "";
   if (value != null)
   {
     valString = value.toString();
   }

   String size = (String) component.getAttributes().get("size");
   if (size == null)
   {
     size = "20";
   }

   String jsfId = (String) component.getAttributes().get("id");
   String id = jsfId;

   if (component.getId() != null &&
     !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
   {
     id = component.getClientId(context);
   }

   writer.write("");
   writer.write("<input ");
   writer.write("");
   writer.write("  value=\"" + valString + "\" ");
   writer.write("  type=\"" + TYPE + "\" ");
   writer.write("  size=\"" + size + "\" ");
   writer.write("  name=\"" + id + "\"");
   writer.write("  id=\"" + id + "\" />&#160;");
   writer.write("<img ");
   writer.write("  style=\"" + CURSORSTYLE + "\" ");
   writer.write("  height=\"" + HEIGHT + "\" ");
   writer.write("  width=\"" + WIDTH + "\"");
   writer.write("  src=\"" + contextPath + "/images/sel.gif\" ");
   writer.write("  border=\"0\"");
   writer.write("  alt=\"" + rb.getString("cp_CLICKALT") + "\" ");
   writer.write("  id=\"_colorPickerPop_" + id + "\"");
   writer.write("  onclick=\"javascript:TCP.popup(" +
     "document.getElementById('" + id + "'),'','" + contextPath +
     "/jsf/widget/colorpicker/')\" />");
   writer.write("&#160;");
 }
 
Example 16
Source File: TimerBarRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
* <p>Faces render output method .</p>
* <p>Method Generator: org.sakaiproject.tool.assessment.devtools.RenderMaker</p>
*
*  @param context   <code>FacesContext</code> for the current request
*  @param component <code>UIComponent</code> being rendered
*
* @throws IOException if an input/output error occurs
*/
 public void encodeEnd(FacesContext context, UIComponent component)
   throws IOException {

    if (!component.isRendered())
    {
      return;
     }

     ResponseWriter writer = context.getResponseWriter();

     String clientId = null;

     if (component.getId() != null &&
       !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
     {
       clientId = component.getClientId(context);
     }

     if (clientId != null)
     {
       writer.startElement("span", component);
       writer.writeAttribute("id", clientId, "id");
     }

     Map attrMap = component.getAttributes();

      writer.write("\n");
      writer.write("\n<script language=\"javascript\">");
      writer.write("\n// Timer Bar - Version 1.0");
      writer.write("\n// Based on Script by Brian Gosselin of http://scriptasylum.com");
      writer.write("\n  var loadedcolor='gray' ;            // PROGRESS BAR COLOR");


      writer.write("\n  var unloadedcolor='green';         // COLOR OF UNLOADED AREA");

      writer.write("\n  var bordercolor='navy';            // COLOR OF THE BORDER");
      writer.write("\n  var barheight = " + attrMap.get("height") + "; // HEIGHT OF PROGRESS BAR IN PIXELS");
      writer.write("\n  var barwidth = " + attrMap.get("width") + "; // WIDTH OF THE BAR IN PIXELS");
      writer.write("\n  var waitTime = " + attrMap.get("wait") + "; // NUMBER OF SECONDS FOR PROGRESSBAR");
      writer.write("\n  var loaded = " + attrMap.get("elapsed") + "*10; // TENTHS OF A SECOND ELAPSED");
      writer.write("\n// THE FUNCTION BELOW CONTAINS THE ACTION(S) TAKEN ONCE BAR REACHES 100.");
      writer.write("\n");
      writer.write("\n  var action = function()");
      writer.write("\n {");
      writer.write("\n   " + attrMap.get("expireScript") + ";");
      writer.write("\n  alert(\""  + attrMap.get("expireMessage") + "\");");
      writer.write("\n }");
      writer.write("\n");
      writer.write("\n</script>");
      writer.write("\n<script language=\"javascript\" src=\"" +
           "/" + RESOURCE_PATH + "/" + SCRIPT_PATH + "\"></script>");
      writer.write("\n");

     if (clientId != null)
       {
       writer.endElement("span");
     }
 }
 
Example 17
Source File: TimerBarRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
* <p>Faces render output method .</p>
* <p>Method Generator: org.sakaiproject.tool.assessment.devtools.RenderMaker</p>
*
*  @param context   <code>FacesContext</code> for the current request
*  @param component <code>UIComponent</code> being rendered
*
* @throws IOException if an input/output error occurs
*/
 public void encodeEnd(FacesContext context, UIComponent component)
   throws IOException {

    if (!component.isRendered())
    {
      return;
     }

     ResponseWriter writer = context.getResponseWriter();

     String clientId = null;

     if (component.getId() != null &&
       !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
     {
       clientId = component.getClientId(context);
     }

     if (clientId != null)
     {
       writer.startElement("span", component);
       writer.writeAttribute("id", clientId, "id");
     }

     Map attrMap = component.getAttributes();

      writer.write("\n");
      writer.write("\n<script language=\"javascript\">");
      writer.write("\n// Timer Bar - Version 1.0");
      writer.write("\n// Based on Script by Brian Gosselin of http://scriptasylum.com");
      writer.write("\n  var loadedcolor='gray' ;            // PROGRESS BAR COLOR");


      writer.write("\n  var unloadedcolor='green';         // COLOR OF UNLOADED AREA");

      writer.write("\n  var bordercolor='navy';            // COLOR OF THE BORDER");
      writer.write("\n  var barheight = " + attrMap.get("height") + "; // HEIGHT OF PROGRESS BAR IN PIXELS");
      writer.write("\n  var barwidth = " + attrMap.get("width") + "; // WIDTH OF THE BAR IN PIXELS");
      writer.write("\n  var waitTime = " + attrMap.get("wait") + "; // NUMBER OF SECONDS FOR PROGRESSBAR");
      writer.write("\n  var loaded = " + attrMap.get("elapsed") + "*10; // TENTHS OF A SECOND ELAPSED");
      writer.write("\n// THE FUNCTION BELOW CONTAINS THE ACTION(S) TAKEN ONCE BAR REACHES 100.");
      writer.write("\n");
      writer.write("\n  var action = function()");
      writer.write("\n {");
      writer.write("\n   " + attrMap.get("expireScript") + ";");
      writer.write("\n  alert(\""  + attrMap.get("expireMessage") + "\");");
      writer.write("\n }");
      writer.write("\n");
      writer.write("\n</script>");
      writer.write("\n<script language=\"javascript\" src=\"" +
           "/" + RESOURCE_PATH + "/" + SCRIPT_PATH + "\"></script>");
      writer.write("\n");

     if (clientId != null)
       {
       writer.endElement("span");
     }
 }
 
Example 18
Source File: ColorPickerRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
  * <p>Faces render output method .</p>
  * <p>Method Generator: org.sakaiproject.tool.assessment.devtoolsRenderMaker</p>
  *
  *  @param context   <code>FacesContext</code> for the current request
  *  @param component <code>UIComponent</code> being rendered
  *
  * @throws IOException if an input/output error occurs
  */
 public void encodeEnd(FacesContext context,
   UIComponent component) throws IOException
 {
ResourceLoader rb= new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages");
   ResponseWriter writer = context.getResponseWriter();
   String contextPath = context.getExternalContext()
                        .getRequestContextPath();

   Object value = null;
   if (component instanceof UIInput)
   {
     value = ( (UIInput) component).getSubmittedValue();
   }
   if (value == null && component instanceof ValueHolder)
   {
     value = ( (ValueHolder) component).getValue();
   }
   String valString = "";
   if (value != null)
   {
     valString = value.toString();
   }

   String size = (String) component.getAttributes().get("size");
   if (size == null)
   {
     size = "20";
   }

   String jsfId = (String) component.getAttributes().get("id");
   String id = jsfId;

   if (component.getId() != null &&
     !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
   {
     id = component.getClientId(context);
   }

   writer.write("");
   writer.write("<input ");
   writer.write("");
   writer.write("  value=\"" + valString + "\" ");
   writer.write("  type=\"" + TYPE + "\" ");
   writer.write("  size=\"" + size + "\" ");
   writer.write("  name=\"" + id + "\"");
   writer.write("  id=\"" + id + "\" />&#160;");
   writer.write("<img ");
   writer.write("  style=\"" + CURSORSTYLE + "\" ");
   writer.write("  height=\"" + HEIGHT + "\" ");
   writer.write("  width=\"" + WIDTH + "\"");
   writer.write("  src=\"" + contextPath + "/images/sel.gif\" ");
   writer.write("  border=\"0\"");
   writer.write("  alt=\"" + rb.getString("cp_CLICKALT") + "\" ");
   writer.write("  id=\"_colorPickerPop_" + id + "\"");
   writer.write("  onclick=\"javascript:TCP.popup(" +
     "document.getElementById('" + id + "'),'','" + contextPath +
     "/jsf/widget/colorpicker/')\" />");
   writer.write("&#160;");
 }
 
Example 19
Source File: SeparatedListRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * We put all our processing in the encodeChildren method
 * @param context
 * @param component
 * @throws IOException
 */
public void encodeChildren(FacesContext context, UIComponent component)
  throws IOException
{
  if (!component.isRendered())
  {
    return;
  }

  String clientId = null;

  if (component.getId() != null &&
    !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
  {
    clientId = component.getClientId(context);
  }

  ResponseWriter writer = context.getResponseWriter();

  if (clientId != null)
  {
     String styleClass = (String) RendererUtil.getAttribute(context, component, "styleClass");
    writer.startElement("div", component);
    writer.writeAttribute("id", clientId, "id");
    writer.writeAttribute("class", styleClass, "class");
  }

  List children = component.getChildren();

  // this is a special separator attribute, not supported by UIData
  String separator = (String) RendererUtil.getAttribute(context, component, "separator");
  if (separator==null) separator=" | ";

  boolean first = true;
  for (Iterator iter = children.iterator(); iter.hasNext();)
  {
    UIComponent child = (UIComponent)iter.next();
     
    if (child.isRendered()) {
       if (!first) writer.write(separator);
 
       RendererUtil.encodeRecursive(context, child);
       first = false;
    }
  } 
    if (clientId != null)
      {
      writer.endElement("div");
    }

  }
 
Example 20
Source File: DataLineRenderer.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * We put all our processing in the encodeChildren method
 * @param context
 * @param component
 * @throws IOException
 */
public void encodeChildren(FacesContext context, UIComponent component)
  throws IOException
{
  if (!component.isRendered())
  {
    return;
  }

  String clientId = null;

  if (component.getId() != null &&
    !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
  {
    clientId = component.getClientId(context);
  }

  ResponseWriter writer = context.getResponseWriter();

  if (clientId != null)
  {
    writer.startElement("span", component);
    writer.writeAttribute("id", clientId, "id");
  }

  UIData data = (UIData) component;

  int first = data.getFirst();
  int rows = data.getRows();

  // this is a special separator attribute, not supported by UIData
  String separator = (String) component.getAttributes().get("separator");
  if (separator==null) separator="";

  for (int i = first, n = 0; n < rows; i++, n++)
  {
    data.setRowIndex(i);
    if (!data.isRowAvailable())
    {
      break;
    }

    // between any two iterations add separator if there is one
    if (i!=first) writer.write(separator);

    Iterator iter = data.getChildren().iterator();
    while (iter.hasNext())
    {
      UIComponent column = (UIComponent) iter.next();
      if (!(column instanceof UIColumn))
      {
        continue;
      }
      RendererUtil.encodeRecursive(context, column);
      }
    }
    if (clientId != null)
      {
      writer.endElement("span");
    }

  }