Package org.ajax4jsf.javascript

Examples of org.ajax4jsf.javascript.JSFunction


        String sliderClientId = slider.getClientId(context);

        String id = slider.getId();

      JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(slider,context);
      ajaxFunction.addParameter(AjaxRendererUtils.buildEventOptions(
        context, slider));
      StringBuffer script= new StringBuffer();
        ajaxFunction.appendScript(script);
        script.append("; return false");
        String sliderHandlerScript = "function updateSlider1(event, value) {\n" +
                                                "$('"+ clientId +"slider_val').value = value;\n" +
                                                script.toString() +
                                                "}\n";
View Full Code Here


      } else {
        flagGroup = Integer.valueOf(1);
      }
    }
    if (itemId != null) {
      JSFunction function = new JSFunction(".addItem");
      function.addParameter(itemId);
      ScriptOptions options = new ScriptOptions(kid);

      options.addEventHandler("onmouseout");
      options.addEventHandler("onmouseover");
     
      if (closeOnClick) {
        options.addOption("closeOnClick", Boolean.TRUE);
      }
      options.addOption("flagGroup", flagGroup);
     
      options.addOption("styleClass");
      options.addOption("style");     
      options.addOption("itemClass");
      options.addOption("itemStyle");
      options.addOption("disabledItemClass");
      options.addOption("disabledItemStyle");
      options.addOption("selectItemClass");
      options.addOption("labelClass");
      options.addOption("selectedLabelClass");
      options.addOption("disabledLabelClass");
     
      options.addOption("selectClass");
      options.addOption("selectStyle");
      options.addOption("iconClass");
     
      if (disabled) {
        options.addOption("disabled", Boolean.TRUE);
      }
     
      options.addEventHandler("onselect");
     
      function.addParameter(options);
      return function.toScript();
    }
    return "";
  }
View Full Code Here

    return selectionHolderInputId;
  }

  protected String getAjaxScript(FacesContext context, UITree tree) {
    String id = tree.getBaseClientId(context);
    JSFunction function = AjaxRendererUtils
    .buildAjaxFunction(tree, context);
    Map eventOptions = AjaxRendererUtils.buildEventOptions(context, tree);
    Map parameters = (Map) eventOptions.get("parameters");
    parameters.remove(id);
    parameters.put(id + UITree.SELECTED_NODE_PARAMETER_NAME,
        new JSReference("event.selectedNode"));
    function.addParameter(eventOptions);
    StringBuffer buffer = new StringBuffer();
    function.appendScript(buffer);
    buffer.append("; return false;");
    return buffer.toString();
  }
View Full Code Here

    final String clientId = tree.getBaseClientId(context);
    StringBuffer sb = new StringBuffer("$(");
    sb.append(ScriptUtils.toScript(clientId));
    sb.append(").component.");
   
    new JSFunction("refreshAfterAjax", encodedAreaIds, getSelectionValue(context, tree)).appendScript(sb);
   
    renderedAreas.add(writeScriptElement(context, tree, sb.toString()));
  }
View Full Code Here

      options.addOption("items", items);
      options.addOption("ajax", ajaxContext.isAjaxRequest());
     
         
      StringBuffer script = new StringBuffer();
      JSFunction function = new JSFunction("new Richfaces.PanelBar");
      function.addParameter(panelBar.getClientId(context));
      function.addParameter(options);
      function.appendScript(script);
     
      ResponseWriter writer = context.getResponseWriter();
      writer.startElement(HTML.SCRIPT_ELEM, panelBar);
      writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
      String outerScript = script.append(";").toString();
View Full Code Here

  /* (non-Javadoc)
   * @see org.richfaces.renderkit.html.AbstractMenuRenderer#getLayerScript(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
   */
  protected String getLayerScript(FacesContext context, UIComponent component) {
    StringBuffer buffer = new StringBuffer();
    JSFunction function = new JSFunction("new RichFaces.Menu.Layer");
    function.addParameter(component.getClientId(context)+"_menu");
    function.addParameter(component.getAttributes().get("showDelay"));
       
    if (component instanceof UIContextMenu) {
        function.addParameter(component.getAttributes().get("hideDelay"));
        } else {
          function.addParameter(new Integer(300));
        }
       
    function.appendScript(buffer);
   
    if (component instanceof UIMenuGroup) {
        buffer.append(".");
        function = new JSFunction("asSubMenu");
        function.addParameter(component.getParent().getClientId(context)+"_menu");
        function.addParameter(component.getClientId(context));
         String evt = (String) component.getAttributes().get("event");
        if(evt == null || evt.trim().length() == 0){
          evt = "onmouseover";
        }
        function.addParameter(evt);
        ScriptOptions subMenuOptions = new ScriptOptions(component);
        subMenuOptions.addEventHandler("onopen");
        subMenuOptions.addEventHandler("onclose");
        subMenuOptions.addOption("direction");
        subMenuOptions.addOption("dummy", "dummy");
        function.addParameter(subMenuOptions);
        function.appendScript(buffer);

    } else {
        buffer.append(".");
        function = new JSFunction("asContextMenu");
/*        function.addParameter(component.getParent().getClientId(context));
          String evt = (String) component.getAttributes().get("event");
        if(evt == null || evt.trim().length() == 0){
          evt = "oncontextmenu";
        }
        function.addParameter(evt);
        function.addParameter("onmouseout");
*/        ScriptOptions menuOptions = new ScriptOptions(component);

        menuOptions.addOption("direction");
        menuOptions.addOption("jointPoint");
        menuOptions.addOption("verticalOffset");


        menuOptions.addOption("horizontalOffset");
        menuOptions.addEventHandler("oncollapse");
        menuOptions.addEventHandler("onexpand");
        menuOptions.addEventHandler("onitemselect");
        menuOptions.addEventHandler("ongroupactivate");
       
        menuOptions.addOption("dummy", "dummy");
        function.addParameter(menuOptions);
        function.appendScript(buffer);

    }
   
    return buffer.toString();
  }
View Full Code Here

   * @throws IOException
   */
  @SuppressWarnings("unchecked")
  public String getActionScript(FacesContext context, UIComponent component) throws IOException {
    String clientId = component.getClientId(context);
    JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(component, context);

    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put(FileUploadConstants.FILE_UPLOAD_ACTION, new JSReference("action"));
    parameters.put(FileUploadConstants.UPLOAD_FILES_ID, new JSReference("uid"));
    parameters.put(AjaxRendererUtils.AJAX_SINGLE_ATTR, clientId);
   
    Map options = AjaxRendererUtils.buildEventOptions(context, component, parameters, true);
    options.put("onbeforedomupdate", new JSReference("callback"));
   
    ajaxFunction.addParameter(options);

    JSFunctionDefinition function = new JSFunctionDefinition("uid", "action", "callback");
    function.addParameter("event");
    function.addToBody(ajaxFunction.toScript());

    return function.toScript();
  }
View Full Code Here

  public Object getSubmitFunction(FacesContext context, UICalendar calendar)
      throws IOException {
   
    if (!UICalendar.AJAX_MODE.equals(calendar.getAttributes().get("mode"))) return null;

    JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(calendar,
        context, AjaxRendererUtils.AJAX_FUNCTION_NAME);
    ajaxFunction.addParameter(JSReference.NULL);
   
    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put(calendar.getClientId(context) + CURRENT_DATE_PRELOAD, Boolean.TRUE);
   
    Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context, calendar, params, true);
    options.put("calendar", JSReference.THIS);

    String oncomplete = AjaxRendererUtils.getAjaxOncomplete(calendar);
    JSFunctionDefinition oncompleteDefinition = new JSFunctionDefinition();
    oncompleteDefinition.addParameter("request");
    oncompleteDefinition.addParameter("event");
    oncompleteDefinition.addParameter("data");
    oncompleteDefinition.addToBody("this.calendar.load(data, true);");
    if (oncomplete != null) {
      oncompleteDefinition.addToBody(oncomplete);
    }

    options.put("oncomplete", oncompleteDefinition);
    JSReference requestValue = new JSReference("requestValue");
    ajaxFunction.addParameter(options);
    JSFunctionDefinition definition = new JSFunctionDefinition();
    definition.addParameter(requestValue);
    definition.addToBody(ajaxFunction);
    return definition;
  }
View Full Code Here

  }

  public static Object formatDate(Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);
    JSFunction result = new JSFunction("new Date");
    result.addParameter(Integer.valueOf(calendar.get(Calendar.YEAR)));
    result.addParameter(Integer.valueOf(calendar.get(Calendar.MONTH)));
    result.addParameter(Integer.valueOf(calendar.get(Calendar.DATE)));

    return result;
  }
View Full Code Here

  public static Object formatSelectedDate(TimeZone timeZone, Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeZone(timeZone);
    calendar.setTime(date);
    JSFunction result = new JSFunction("new Date");
    result.addParameter(Integer.valueOf(calendar.get(Calendar.YEAR)));
    result.addParameter(Integer.valueOf(calendar.get(Calendar.MONTH)));
    result.addParameter(Integer.valueOf(calendar.get(Calendar.DATE)));
    result
        .addParameter(Integer.valueOf(calendar
            .get(Calendar.HOUR_OF_DAY)));
    result.addParameter(Integer.valueOf(calendar.get(Calendar.MINUTE)));
    result.addParameter(new Integer(0));
    return result;
  }
View Full Code Here

TOP

Related Classes of org.ajax4jsf.javascript.JSFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.