Package org.primefaces.model

Examples of org.primefaces.model.DualListModel



  protected void validateValue(FacesContext facesContext, Object newValue) {
    super.validateValue(facesContext, newValue);
   
    DualListModel model = (DualListModel) newValue;
    if(isRequired() && model.getTarget().isEmpty()) {
      String requiredMessage = getRequiredMessage();
      FacesMessage message = null;
     
      if(requiredMessage != null)
        message = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage);
View Full Code Here


  @SuppressWarnings("unchecked")
  private void encodeMarkup(FacesContext facesContext, PickList pickList) throws IOException {
    ResponseWriter writer = facesContext.getResponseWriter();
    String clientId = pickList.getClientId(facesContext);
    String widgetVar = createUniqueWidgetVar(facesContext, pickList);
    DualListModel model = (DualListModel) pickList.getValue();
   
    writer.startElement("table", pickList);
    writer.writeAttribute("id", clientId, "id");
    if(pickList.getStyle() != null) writer.writeAttribute("style", pickList.getStyle(), null);
    if(pickList.getStyleClass() != null) writer.writeAttribute("class", pickList.getStyleClass(), null);
   
    writer.startElement("tbody", null);
    writer.startElement("tr", null);
   
    //Source
    writer.startElement("td", null);
    encodeList(facesContext, pickList, clientId + "_source", widgetVar, "ui-picklist-source", model.getSource());
    writer.endElement("td");
   
    //Controls
    writer.startElement("td", null);
    if(pickList.getFacetCount() > 0) {
      encodeFacet(facesContext, pickList, widgetVar, "add");
      encodeFacet(facesContext, pickList, widgetVar, "addAll");
      encodeFacet(facesContext, pickList, widgetVar, "remove");
      encodeFacet(facesContext, pickList, widgetVar, "removeAll");
    } else {
      encodeDefaultControl(facesContext, pickList, widgetVar, ">", "add");
      encodeDefaultControl(facesContext, pickList, widgetVar, ">>", "addAll");
      encodeDefaultControl(facesContext, pickList, widgetVar, "<", "remove");
      encodeDefaultControl(facesContext, pickList, widgetVar, "<<", "removeAll");
    }
    writer.endElement("td");
   
    //Target
    writer.startElement("td", null);
    encodeList(facesContext, pickList, clientId + "_target", widgetVar, "ui-picklist-target", model.getTarget());
    writer.endElement("td");
   
    writer.endElement("tr");
    writer.endElement("tbody");
   
View Full Code Here

  public Object getConvertedValue(FacesContext facesContext, UIComponent component, Object submittedValue) throws ConverterException {
    PickList pickList = (PickList) component;
    String[] value = (String[]) submittedValue;
    String[] sourceList = value[0].split(";");
    String[] targetList = value[1].split(";");
    DualListModel model = new DualListModel();
   
    doConvertValue(facesContext, pickList, sourceList, model.getSource());
    doConvertValue(facesContext, pickList, targetList, model.getTarget());
       
    return model;
  }
View Full Code Here

  }

    protected void encodeMarkup(FacesContext context, PickList pickList) throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    String clientId = pickList.getClientId(context);
    DualListModel model = (DualListModel) pickList.getValue();
        String styleClass = pickList.getStyleClass();
        styleClass = styleClass == null ? PickList.CONTAINER_CLASS : PickList.CONTAINER_CLASS + " " + styleClass;
        String labelDisplay = pickList.getLabelDisplay();

    writer.startElement("div", pickList);
    writer.writeAttribute("id", clientId, "id");
        writer.writeAttribute("class", styleClass, null);
    if(pickList.getStyle() != null) {
            writer.writeAttribute("style", pickList.getStyle(), null);
        }

        //Target List Reorder Buttons
        if(pickList.isShowSourceControls()) {
            encodeListControls(context, pickList, PickList.SOURCE_CONTROLS, labelDisplay);
        }
    //Source List
    encodeList(context, pickList, clientId + "_source", PickList.SOURCE_CLASS, model.getSource(), pickList.getFacet("sourceCaption"), pickList.isShowSourceFilter());

    //Buttons
    writer.startElement("div", null);
        writer.writeAttribute("class", PickList.BUTTONS_CLASS, null);
        writer.startElement("div", null);
        writer.writeAttribute("class", PickList.BUTTONS_CELL_CLASS, null);
        encodeButton(context, pickList.getAddLabel(), PickList.ADD_BUTTON_CLASS, PickList.ADD_BUTTON_ICON_CLASS, labelDisplay);
        encodeButton(context, pickList.getAddAllLabel(), PickList.ADD_ALL_BUTTON_CLASS, PickList.ADD_ALL_BUTTON_ICON_CLASS, labelDisplay);
        encodeButton(context, pickList.getRemoveLabel(), PickList.REMOVE_BUTTON_CLASS, PickList.REMOVE_BUTTON_ICON_CLASS, labelDisplay);
        encodeButton(context, pickList.getRemoveAllLabel(), PickList.REMOVE_ALL_BUTTON_CLASS, PickList.REMOVE_ALL_BUTTON_ICON_CLASS, labelDisplay);
    writer.endElement("div");
        writer.endElement("div");

    //Target List
    encodeList(context, pickList, clientId + "_target", PickList.TARGET_CLASS, model.getTarget(), pickList.getFacet("targetCaption"), pickList.isShowTargetFilter());

        //Target List Reorder Buttons
        if(pickList.isShowTargetControls()) {
            encodeListControls(context, pickList, PickList.TARGET_CONTROLS, labelDisplay);
        }
View Full Code Here

        try {
            PickList pickList = (PickList) component;
            String[][] value = (String[][]) submittedValue;
            String[] sourceValue = value[0];
            String[] targetValue = value[1];
            DualListModel model = new DualListModel();

            pickList.populateModel(context, sourceValue, model.getSource());
            pickList.populateModel(context, targetValue, model.getTarget());

            return model;
        }
        catch(Exception exception) {
            throw new ConverterException(exception);
View Full Code Here

    public Object getAsObject(FacesContext fc, UIComponent uic, final String value) {
        if (value != null && value.trim().length() > 0) {
            Object ret = null;
            if (uic instanceof PickList) {
                Object dualList = ((PickList) uic).getValue();
                DualListModel dl = (DualListModel) dualList;
                for (Iterator iterator = dl.getSource().iterator(); iterator.hasNext();) {
                    Object o = iterator.next();
                    String id = (new StringBuilder()).append(((IpsBloqueados) o).getIdIpBloqueado()).toString();
                    if (value.equals(id)) {
                        ret = o;
                        break;
                    }
                }
                if (ret == null) {
                    for (Iterator iterator1 = dl.getTarget().iterator(); iterator1.hasNext();) {
                        Object o = iterator1.next();
                        String id = (new StringBuilder()).append(((IpsBloqueados) o).getIdIpBloqueado()).toString();
                        if (value.equals(id)) {
                            ret = o;
                            break;
View Full Code Here

    public static final String CAPTION_CLASS = "ui-picklist-caption ui-widget-header ui-corner-tl ui-corner-tr";

  protected void validateValue(FacesContext facesContext, Object newValue) {
    super.validateValue(facesContext, newValue);
   
    DualListModel model = (DualListModel) newValue;
    if(isRequired() && model.getTarget().isEmpty()) {
      String requiredMessage = getRequiredMessage();
      FacesMessage message = null;
     
      if(requiredMessage != null)
        message = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage);
View Full Code Here

  }

    protected void encodeMarkup(FacesContext context, PickList pickList) throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    String clientId = pickList.getClientId(context);
    DualListModel model = (DualListModel) pickList.getValue();
        String styleClass = pickList.getStyleClass();
        styleClass = styleClass == null ? PickList.CONTAINER_CLASS : PickList.CONTAINER_CLASS + " " + styleClass;

    writer.startElement("table", pickList);
    writer.writeAttribute("id", clientId, "id");
        writer.writeAttribute("class", styleClass, null);
    if(pickList.getStyle() != null) {
            writer.writeAttribute("style", pickList.getStyle(), null);
        }

    writer.startElement("tbody", null);
    writer.startElement("tr", null);

        //Target List Reorder Buttons
        if(pickList.isShowSourceControls()) {
            encodeListControls(context, pickList, PickList.SOURCE_CONTROLS);
        }
    //Source List
    encodeList(context, pickList, clientId + "_source", PickList.SOURCE_CLASS, model.getSource(), pickList.getFacet("sourceCaption"));

    //Buttons
    writer.startElement("td", null);
        encodeButton(context, pickList, pickList.getAddLabel(), PickList.ADD_BUTTON_CLASS);
        encodeButton(context, pickList, pickList.getAddAllLabel(), PickList.ADD_ALL_BUTTON_CLASS);
        encodeButton(context, pickList, pickList.getRemoveLabel(), PickList.REMOVE_BUTTON_CLASS);
        encodeButton(context, pickList, pickList.getRemoveAllLabel(), PickList.REMOVE_ALL_BUTTON_CLASS);
    writer.endElement("td");

    //Target List
    encodeList(context, pickList, clientId + "_target", PickList.TARGET_CLASS, model.getTarget(), pickList.getFacet("targetCaption"));

        //Target List Reorder Buttons
        if(pickList.isShowTargetControls()) {
            encodeListControls(context, pickList, PickList.TARGET_CONTROLS);
        }
View Full Code Here

  public Object getConvertedValue(FacesContext facesContext, UIComponent component, Object submittedValue) throws ConverterException {
    PickList pickList = (PickList) component;
    String[] value = (String[]) submittedValue;
    String[] sourceList = value[0].split(",");
    String[] targetList = value[1].split(",");
    DualListModel model = new DualListModel();
   
    doConvertValue(facesContext, pickList, sourceList, model.getSource());
    doConvertValue(facesContext, pickList, targetList, model.getTarget());
       
    return model;
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private void encodeMarkup(FacesContext facesContext, PickList pickList) throws IOException {
    ResponseWriter writer = facesContext.getResponseWriter();
    String clientId = pickList.getClientId(facesContext);
    String widgetVar = createUniqueWidgetVar(facesContext, pickList);
    DualListModel model = (DualListModel) pickList.getValue();
   
    writer.startElement("table", pickList);
    writer.writeAttribute("id", clientId, "id");
    if(pickList.getStyle() != null) writer.writeAttribute("style", pickList.getStyle(), null);
    if(pickList.getStyleClass() != null) writer.writeAttribute("class", pickList.getStyleClass(), null);
   
    writer.startElement("tbody", null);
    writer.startElement("tr", null);
   
    //Source
    writer.startElement("td", null);
    encodeList(facesContext, pickList, clientId + "_source", widgetVar, "pf-picklist-source", model.getSource());
    writer.endElement("td");
   
    //Controls
    writer.startElement("td", null);
    if(pickList.getFacetCount() > 0) {
      encodeFacet(facesContext, pickList, widgetVar, "add");
      encodeFacet(facesContext, pickList, widgetVar, "addAll");
      encodeFacet(facesContext, pickList, widgetVar, "remove");
      encodeFacet(facesContext, pickList, widgetVar, "removeAll");
    } else {
      encodeDefaultControl(facesContext, pickList, widgetVar, ">", "add");
      encodeDefaultControl(facesContext, pickList, widgetVar, ">>", "addAll");
      encodeDefaultControl(facesContext, pickList, widgetVar, "<", "remove");
      encodeDefaultControl(facesContext, pickList, widgetVar, "<<", "removeAll");
    }
    writer.endElement("td");
   
    //Target
    writer.startElement("td", null);
    encodeList(facesContext, pickList, clientId + "_target", widgetVar, "pf-picklist-target", model.getTarget());
    writer.endElement("td");
   
    writer.endElement("tr");
    writer.endElement("tbody");
   
View Full Code Here

TOP

Related Classes of org.primefaces.model.DualListModel

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.