Package org.richfaces.component

Examples of org.richfaces.component.UITogglePanel


    if (clnId != null) {
      // enqueue event here for this component or for component with Id
      // taken fro forId attribute
      UIToggleControl control = (UIToggleControl)component;

      UITogglePanel panel = control.getPanel();

          new SwitchablePanelSwitchEvent(panel, null, control).queue();
     
        if (UITogglePanel.AJAX_METHOD.equals(panel.getSwitchType())) {
           new AjaxEvent(component).queue();
          
                // add regions specified in the "reRender" attribute of toggle
                // panel to rendered list of components
                AjaxRendererUtils.addRegionsFromComponent(control, context);
View Full Code Here


    }
  }

  public String getOnClick(FacesContext context, UIComponent component) {
    UIToggleControl tgComp = (UIToggleControl)component;
    UITogglePanel panel = tgComp.getPanel();
    //UITogglePanel panel = tgComp.getPanel(context);
    //denis
    String switchType = panel.getSwitchType();
    StringBuffer onClick = new StringBuffer();
    String userOnClick = (String)component.getAttributes().get("onclick");
    if(userOnClick!=null) {
      onClick.append(userOnClick);
      if(!userOnClick.trim().endsWith(";")) {
        onClick.append("; ");
      }
    }

    if(UITogglePanel.CLIENT_METHOD.equals(switchType)) {
      // Client
      String panelId = panel.getClientId(context);
      String switchToDivId = tgComp.getSwitchToState();
      onClick.append("TogglePanelManager.toggleOnClient('")
      .append(panelId).append("',")
      .append(switchToDivId==null?"null":"'" + switchToDivId + "'")
      .append(");");
View Full Code Here

  public void doDecode(FacesContext context, UIComponent component) {
    super.doDecode(context, component);
    Map<String, String> rqMap = context.getExternalContext().getRequestParameterMap();
    Object clnId = rqMap.get(component.getClientId(context));
    UITogglePanel panel = (UITogglePanel)component;
    if (clnId != null) {
      if (UITogglePanel.CLIENT_METHOD.equals(panel.getSwitchType())) {
        new SwitchablePanelSwitchEvent(panel, clnId, null).queue();
      }
    }
  }
View Full Code Here

    return child;
  }

  //xxx by nick - denis - do not catch exception, rethrow them
  public void handleFacets(FacesContext context, UITogglePanel component) throws IOException  {
    UITogglePanel panel = (UITogglePanel)component;
    List<String> stateOrderList = component.getStateOrderList();
    String state = (String) component.getValue();
    if (state == null) {
      String initialState = component.getInitialState();
      if (initialState != null) {
        state = initialState;
      } else {
          if (!stateOrderList.isEmpty()) {
          state = (String) stateOrderList.get(0);
          } else {
            throw new FacesException("The \"initialState\" attribute of the togglePanel component should be set if \"stateOrder\" attribute is empty!");
          }
      }
    }
   
    ResponseWriter out = context.getResponseWriter();
    String switchType = panel.getSwitchType();
    if (UITogglePanel.CLIENT_METHOD.equals(switchType)) {
      // Client
      String panelId = panel.getClientId(context);
      StringBuffer divIds = new StringBuffer();
      boolean first = true;

      for (Iterator<String> iterator = stateOrderList.iterator(); iterator.hasNext();) {
        String stateName = (String) iterator.next();

        UIComponent child = getFacet(component, stateName);
        if(!first) {
          divIds.append("\", \"");
        }
        divIds.append(stateName);
        first = false;

        String id = panel.getClientId(context) + "_" + stateName;

        out.startElement("div", component);
        out.writeAttribute("id", id, null);
        out.writeAttribute("style", "display: " + (stateName.equals(state) ? "inherit": "none"), null);
        renderChild(context, child);
        out.endElement("div");
      }

      String idInput = panel.getClientId(context) + "_input";
      out.startElement("div", component);
      out.writeAttribute("style", "display: none;", null);
      out.startElement("input", component);
      out.writeAttribute("type", "hidden", null);
      out.writeAttribute("id", idInput, null);
      out.writeAttribute("name", panel.getClientId(context), null);
      out.writeAttribute("value", state, null);
      out.endElement("input");
      out.endElement("div");

     
      String script =  MessageFormat.format(CLIENT_SCRIPT,
              panelId, divIds.toString(), state);
      out.write(script);

//      } else if(UITogglePanel.AJAX_METHOD.equals(switchType)) {
//      // Ajax
//      UIComponent child = getFacet(component, state);
//      if(child != null) {
//      out.startElement("div", component);
//      renderChild(context, child);
//      out.endElement("div");
//      }
    } else {
      // Server or AJAX
      UIComponent child = getFacet(component, state);
      if(child != null) {
        out.startElement("div", component);
        renderChild(context, child);
        out.endElement("div");
      }
    }
    panel.setValue(state);
  }
View Full Code Here

    if(clnId!=null) {
      // enqueue event here for this component or for component with Id
      // taken fro forId attribute
      UIToggleControl control = (UIToggleControl)component;

      UITogglePanel panel = control.getPanel();

          new SwitchablePanelSwitchEvent(panel, null, control).queue();
     
//      ToggleEvent event = new ToggleEvent(panel, control.getSwitchToState());
//        if (control.isImmediate()) {
//          event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
//        } else {
//          event.setPhaseId(PhaseId.INVOKE_APPLICATION);
//        }
//        event.queue();
       
        if(UITogglePanel.AJAX_METHOD.equals(panel.getSwitchType())) {
           new AjaxEvent(component).queue();
        }
        ActionEvent actionEvent = new ActionEvent(component);
        component.queueEvent(actionEvent);
    }
View Full Code Here

    }
  }

  public String getOnClick(FacesContext context, UIComponent component) {
    UIToggleControl tgComp = (UIToggleControl)component;
    UITogglePanel panel = tgComp.getPanel();
    //UITogglePanel panel = tgComp.getPanel(context);
    //denis
    String switchType = panel.getSwitchType();
    StringBuffer onClick = new StringBuffer();
    String userOnClick = (String)component.getAttributes().get("onclick");
    if(userOnClick!=null) {
      onClick.append(userOnClick);
      if(!userOnClick.trim().endsWith(";")) {
        onClick.append("; ");
      }
    }

    if(UITogglePanel.CLIENT_METHOD.equals(switchType)) {
      // Client
      String panelId = panel.getClientId(context);
      String switchToDivId = tgComp.getSwitchToState();
      onClick.append("TogglePanelManager.toggleOnClient('")
      .append(panelId)
      .append("',")
      .append(switchToDivId==null?"null":"'" + switchToDivId + "'")
View Full Code Here

  public void doDecode(FacesContext context, UIComponent component) {
    super.doDecode(context, component);
    ExternalContext exCtx = context.getExternalContext();
    Map rqMap = exCtx.getRequestParameterMap();
    Object clnId = rqMap.get(component.getClientId(context));
    UITogglePanel panel = (UITogglePanel)component;
    if (clnId!=null) {
      if (UITogglePanel.CLIENT_METHOD.equals(panel.getSwitchType())) {
        new SwitchablePanelSwitchEvent(panel, (String) clnId, null).queue();
      }
    }
  }
View Full Code Here

    return child;
  }

  //xxx by nick - denis - do not catch exception, rethrow them
  public void handleFacets(FacesContext context, UITogglePanel component) throws IOException  {
    UITogglePanel panel = (UITogglePanel)component;
    List stateOrderList = component.getStateOrderList();
    String state = (String) component.getValue();
    if (state == null) {
      String initialState = component.getInitialState();
      if(initialState != null) {       
        state = initialState;
      } else {
          if (!stateOrderList.isEmpty()) {
          state = (String) stateOrderList.get(0);
          } else {
            throw new FacesException("The \"initialState\" attribute of the togglePanel component should be set if \"stateOrder\" attribute is empty!");
          }
      }   
    }
   
    ResponseWriter out = context.getResponseWriter();
    String switchType = panel.getSwitchType();
    if(UITogglePanel.CLIENT_METHOD.equals(switchType)) {
      // Client
      String panelId = panel.getClientId(context);
      StringBuffer divIds = new StringBuffer();
      boolean first = true;

      for (Iterator iterator = stateOrderList.iterator(); iterator.hasNext();) {
        String stateName = (String) iterator.next();

        UIComponent child = getFacet(component, stateName);
        if(!first) {
          divIds.append("\", \"");
        }
        divIds.append(stateName);
        first = false;

        String id = panel.getClientId(context) + "_" + stateName;

        out.startElement("div", component);
        out.writeAttribute("id", id, null);
        out.writeAttribute("style", "display: " + (stateName.equals(state) ? "inherit": "none"), null);
        renderChild(context, child);
        out.endElement("div");
      }

      String idInput = panel.getClientId(context) + "_input";
      out.startElement("div", component);
      out.writeAttribute("style", "display: none;", null);
      out.startElement("input", component);
      out.writeAttribute("type", "hidden", null);
      out.writeAttribute("id", idInput, null);
      out.writeAttribute("name", panel.getClientId(context), null);
      out.writeAttribute("value", state, null);
      out.endElement("input");
      out.endElement("div");

      String script =  MessageFormat.format(CLIENT_SCRIPT, new Object[]{panelId, divIds.toString(), state});
      out.write(script);

//      } else if(UITogglePanel.AJAX_METHOD.equals(switchType)) {
//      // Ajax
//      UIComponent child = getFacet(component, state);
//      if(child != null) {
//      out.startElement("div", component);
//      renderChild(context, child);
//      out.endElement("div");
//      }
    } else {
      // Server or AJAX
      UIComponent child = getFacet(component, state);
      if(child != null) {
        out.startElement("div", component);
        renderChild(context, child);
        out.endElement("div");
      }
    }
    panel.setValue(state);
  }
View Full Code Here

    if(clnId!=null) {
      // enqueue event here for this component or for component with Id
      // taken fro forId attribute
      UIToggleControl control = (UIToggleControl)component;

      UITogglePanel panel = control.getPanel();

          new SwitchablePanelSwitchEvent(panel, null, control).queue();
     
//      ToggleEvent event = new ToggleEvent(panel, control.getSwitchToState());
//        if (control.isImmediate()) {
//          event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
//        } else {
//          event.setPhaseId(PhaseId.INVOKE_APPLICATION);
//        }
//        event.queue();
       
        //TODO by nick - nick - why check here?
        if(!UITogglePanel.AJAX_METHOD.equals(panel.getSwitchType())) {
          ActionEvent actionEvent = new ActionEvent(component);
          component.queueEvent(actionEvent);
        }
    }
  }
View Full Code Here

    }
  }

  public String getOnClick(FacesContext context, UIComponent component) {
    UIToggleControl tgComp = (UIToggleControl)component;
    UITogglePanel panel = tgComp.getPanel();
    //UITogglePanel panel = tgComp.getPanel(context);
    //denis
    String switchType = panel.getSwitchType();
    StringBuffer onClick = new StringBuffer();
    String userOnClick = (String)component.getAttributes().get("onclick");
    if(userOnClick!=null) {
      onClick.append(userOnClick);
      if(!userOnClick.trim().endsWith(";")) {
        onClick.append("; ");
      }
    }

    if(UITogglePanel.CLIENT_METHOD.equals(switchType)) {
      // Client
      String panelId = panel.getClientId(context);
      String switchToDivId = tgComp.getSwitchToState();
      onClick.append("TogglePanelManager.toggleOnClient('")
      .append(panelId)
      .append("',")
      .append(switchToDivId==null?"null":"'" + switchToDivId + "'")
View Full Code Here

TOP

Related Classes of org.richfaces.component.UITogglePanel

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.