Package org.richfaces.component

Examples of org.richfaces.component.UISuggestionBox


        String clientId = component.getClientId(context);
        Map<String, String> requestParameterMap = context.getExternalContext()
                .getRequestParameterMap();
        String reqValue = requestParameterMap.get(clientId);
        if (reqValue != null && reqValue.equals(clientId)) {
            UISuggestionBox suggestionBox = ((UISuggestionBox) component);
            String paramName = (String) component.getAttributes().get("param");
            if (null == paramName) {
                paramName = "inputvalue";
            }
            String elementValue = requestParameterMap.get(paramName);
            suggestionBox.setSubmitted(true);
            component.queueEvent(
                    new AjaxSuggestionEvent(component, elementValue));

            String[] requestedValues = null;

            if (suggestionBox.isUsingSuggestObjects()) {
                String requestedParamName = paramName + "request";
                String requestedValuesParam = requestParameterMap.get(requestedParamName);

                if (requestedValuesParam != null) {
              String requestedString = requestedValuesParam.toString();
              Pattern pattern = getTokensPattern(component);

              if (pattern != null) {
            requestedValues = pattern.split(requestedString);
              } else {
            requestedValues = new String[] {requestedString};
              }
          } else {
              //TODO nick - review together with pasha
          }
            }

            suggestionBox.setSubmitedValue(elementValue,
              requestedValues);
        }
    }
View Full Code Here


     * @see {@link org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd}
     */
    protected void doEncodeEnd(final ResponseWriter writer,
                               final FacesContext context,
                               final UIComponent component) throws IOException {
        UISuggestionBox suggestionBox = (UISuggestionBox) component;
        if (!suggestionBox.isSubmitted()) {
            suggestionBox.setRowIndex(-1);
            writer.startElement(HTML.DIV_ELEM, component);
            getUtils().encodeId(context, component);

            StringBuffer clazz = new StringBuffer(
                    "dr-sb-common-container rich-sb-common-container ");
            clazz.append(suggestionBox.getPopupClass() + " ").
              append(suggestionBox.getStyleClass());
            writer.writeAttribute("class", clazz, "popupClass");

            int zIndex = suggestionBox.getZindex();

            StringBuffer style = new StringBuffer("display:none; z-index: " + (zIndex + 1) + ";");

            style.append(getSizeForStyle(component, "width", null, false));
            style.append(getSizeForStyle(component, "height", null, false));

            style.append(suggestionBox.getPopupStyle() + ";").
              append(suggestionBox.getStyle() + ";");
            writer.writeAttribute("style", style, "popupStyle");

            UIComponent popupFacet = component.getFacet("popup");
            if (null == popupFacet) {
                popup.encode(this, context, component);
            } else {
                // Use facet as content of popup window
                // suggestionBox.setPopup(popupFacet.getClientId(context));
                renderChild(context, popupFacet);
            }
            writer.endElement(HTML.DIV_ELEM);
           
            writer.startElement(HTML.DIV_ELEM, component);
            writer.writeAttribute("id", component.getClientId(context) + "_script", null);
            writer.writeAttribute("style", "display:none;", null);
            writer.startElement(HTML.SCRIPT_ELEM, component);
            writer.writeAttribute("type", "text/javascript", null);
            writer.writeText(getScript(context, component), "script");
            writer.endElement(HTML.SCRIPT_ELEM);
            writer.endElement(HTML.DIV_ELEM);
           
            writer.startElement("iframe", component);
            writer.writeAttribute("src",
                getResource("/org/richfaces/renderkit/html/images/spacer.gif")
                    .getUri(context, null), null);
            writer.writeAttribute("id", component.getClientId(context)
                    + "_iframe", null);
            writer.writeAttribute(
                    "style", "position:absolute;display:none;z-index:" + zIndex + ";", null);
            writer.endElement("iframe");

            writer.startElement("input", component);
        writer.writeAttribute("type", "hidden", null);
        writer.writeAttribute("id", component.getClientId(context)
                    + "_selection", null);
        writer.writeAttribute("name", component.getClientId(context)
                    + "_selection", null);
        writer.endElement("input");
           
        } else {
            suggestionBox.setSubmitted(false);
        }

        // Fix for bug CH-1323.
        ((UISuggestionBox) component).setValue(null);
    }
View Full Code Here

     * @see javax.faces.render.Renderer#encodeChildren
     */
    public void encodeChildren(final FacesContext context,
                               final UIComponent component)
            throws IOException {
        UISuggestionBox suggestionBox = (UISuggestionBox) component;
        AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
        Set<String> ajaxRenderedAreas = ajaxContext.getAjaxRenderedAreas();
        String clientId = component.getClientId(context);
       
        if (suggestionBox.isSubmitted()) {
            body.encode(getTemplateContext(context, suggestionBox));
            // Replace rendered area ID from component to suggestion table
            suggestionBox.setRowIndex(-1);
            ajaxContext.removeRenderedArea(clientId);
            ajaxContext.addRenderedArea(getContentId(context, component));
        }
        else if (ajaxContext.isAjaxRequest() && ajaxRenderedAreas.contains(clientId))
        {
View Full Code Here

            select = "richfaces_suggestionSelectValue";
          }
            options.put("select", select);
        }
       
        UISuggestionBox suggestionBox = (UISuggestionBox) component;
        options.put("usingSuggestObjects", suggestionBox.isUsingSuggestObjects());

        // pass "zindex" attribute to js though the "options" attribute
        options.put("zindex", suggestionBox.getZindex());

        submitSuggest.addParameter(options);
        script.append(submitSuggest.toScript()).append(";\n");
        return "Richfaces.onAvailable('" + targetId + "', function() {" + script.toString() + "});";
    }
View Full Code Here

     * @param component {@link javax.faces.component.UIComponent}
     * @return cellpadding style
     */
    public final String cellPadding(final FacesContext context,
                                    final UIComponent component) {
        UISuggestionBox box = (UISuggestionBox) component;
        String cp = box.getCellpadding();
        if (cp != null) {
            return "padding: " + getUtils().encodePctOrPx(cp) + ";";
        }
        return ";";
    }
View Full Code Here

    }
   
    public void insertNothingLabel(final FacesContext context,
                                    final UIComponent component) throws IOException {
      ResponseWriter writer = context.getResponseWriter();
      UISuggestionBox suggestionBox = (UISuggestionBox)component;
      final String startHtml =
        "<tr id=\"" + suggestionBox.getClientId(context) + "NothingLabel\" class=\"dr-sb-int rich-sb-int " + suggestionBox.getRowClasses() +
        "\" style=\"display: none;\">" +
        "<td nowrap=\"nowrap\" class=\"dr-sb-cell-padding rich-sb-cell-padding\" style=\"" + this.cellPadding(context, component) + "\">";
      final String endHtml = "</td></tr>";
     
      UIComponent nothingLabelFacet = component.getFacet("nothingLabel");
      if(null != nothingLabelFacet && nothingLabelFacet.isRendered()) {
        writer.write(startHtml);
        renderChild(context, nothingLabelFacet);
        writer.write(endHtml);
      }
      else {
        String nothingLabel = suggestionBox.getNothingLabel();
      if (null != nothingLabel &&
            !"".equals(nothingLabel)) {
          writer.write(startHtml);
          writer.write(nothingLabel);
          writer.write(endHtml);
View Full Code Here

                        this.putParameter("hasColumnFooter", Boolean.TRUE);
                    }
                }
            }
            // fill rows counters
            UISuggestionBox box = (UISuggestionBox) component;
            this.first = box.getFirst();
            this.rows = box.getRows();
            this.rowCount = box.getRowCount();
            // return all records; CH-1330
            if (rows <= 0 || true) {
                rows = rowCount - first;
            }
            last = first + rows;
            if (last > rowCount) {
                last = rowCount;
            }
            current = first;
            // rows classes
            entryClass = box.getEntryClass();
            String rowClasses = box.getRowClasses();
            if (null != rowClasses && rowClasses.length() > 0) {
                this.rowClasses = rowClasses.split("\\s+");
            }

        }
View Full Code Here

        String clientId = component.getClientId(context);
        Map<String, String> requestParameterMap = context.getExternalContext()
                .getRequestParameterMap();
        String reqValue = requestParameterMap.get(clientId);
        if (reqValue != null && reqValue.equals(clientId)) {
            UISuggestionBox suggestionBox = ((UISuggestionBox) component);
            String paramName = (String) component.getAttributes().get("param");
            if (null == paramName) {
                paramName = "inputvalue";
            }
            String elementValue = requestParameterMap.get(paramName);
            suggestionBox.setSubmitted(true);
            component.queueEvent(
                    new AjaxSuggestionEvent(component, elementValue));

            String[] requestedValues = null;

            if (suggestionBox.isUsingSuggestObjects()) {
                String requestedParamName = paramName + "request";
                String requestedValuesParam = requestParameterMap.get(requestedParamName);

                if (requestedValuesParam != null) {
              String requestedString = requestedValuesParam.toString();
              Pattern pattern = getTokensPattern(component);

              if (pattern != null) {
            requestedValues = pattern.split(requestedString);
              } else {
            requestedValues = new String[] {requestedString};
              }
          } else {
              //TODO nick - review together with pasha
          }
            }

            suggestionBox.setSubmitedValue(elementValue,
              requestedValues);
        }
    }
View Full Code Here

     * @see {@link org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd}
     */
    protected void doEncodeEnd(final ResponseWriter writer,
                               final FacesContext context,
                               final UIComponent component) throws IOException {
        UISuggestionBox suggestionBox = (UISuggestionBox) component;
        if (!suggestionBox.isSubmitted()) {
            suggestionBox.setRowIndex(-1);
            writer.startElement(HTML.DIV_ELEM, component);
            getUtils().encodeId(context, component);

            StringBuffer clazz = new StringBuffer(
                    "dr-sb-common-container rich-sb-common-container ");
            clazz.append(suggestionBox.getPopupClass() + " ").
              append(suggestionBox.getStyleClass());
            writer.writeAttribute("class", clazz, "popupClass");

            int zIndex = suggestionBox.getZindex();

            StringBuffer style = new StringBuffer("display:none; z-index: " + (zIndex + 1) + ";");

            style.append(getSizeForStyle(component, "width", null, false));
            style.append(getSizeForStyle(component, "height", null, false));

            style.append(suggestionBox.getPopupStyle() + ";").
              append(suggestionBox.getStyle() + ";");
            writer.writeAttribute("style", style, "popupStyle");

            UIComponent popupFacet = component.getFacet("popup");
            if (null == popupFacet) {
                popup.encode(this, context, component);
            } else {
                // Use facet as content of popup window
                // suggestionBox.setPopup(popupFacet.getClientId(context));
                renderChild(context, popupFacet);
            }
            writer.endElement(HTML.DIV_ELEM);
           
            writer.startElement(HTML.DIV_ELEM, component);
            writer.writeAttribute("id", component.getClientId(context) + "_script", null);
            writer.writeAttribute("style", "display:none;", null);
            writer.startElement(HTML.SCRIPT_ELEM, component);
            writer.writeText(getScript(context, component), "script");
            writer.endElement(HTML.SCRIPT_ELEM);
            writer.endElement(HTML.DIV_ELEM);
           
            writer.startElement("iframe", component);
            writer.writeAttribute("src",
                getResource("/org/richfaces/renderkit/html/images/spacer.gif")
                    .getUri(context, null), null);
            writer.writeAttribute("id", component.getClientId(context)
                    + "_iframe", null);
            writer.writeAttribute(
                    "style", "position:absolute;display:none;z-index:" + zIndex + ";", null);
            writer.endElement("iframe");

            writer.startElement("input", component);
        writer.writeAttribute("type", "hidden", null);
        writer.writeAttribute("id", component.getClientId(context)
                    + "_selection", null);
        writer.writeAttribute("name", component.getClientId(context)
                    + "_selection", null);
        writer.endElement("input");
           
        } else {
            suggestionBox.setSubmitted(false);
        }

        // Fix for bug CH-1323.
        ((UISuggestionBox) component).setValue(null);
    }
View Full Code Here

     * @see javax.faces.render.Renderer#encodeChildren
     */
    public void encodeChildren(final FacesContext context,
                               final UIComponent component)
            throws IOException {
        UISuggestionBox suggestionBox = (UISuggestionBox) component;
        AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
        Set<String> ajaxRenderedAreas = ajaxContext.getAjaxRenderedAreas();
        String clientId = component.getClientId(context);
       
        if (suggestionBox.isSubmitted()) {
            body.encode(getTemplateContext(context, suggestionBox));
            // Replace rendered area ID from component to suggestion table
            suggestionBox.setRowIndex(-1);
            ajaxContext.removeRenderedArea(clientId);
            ajaxContext.addRenderedArea(getContentId(context, component));
        }
        else if (ajaxContext.isAjaxRequest() && ajaxRenderedAreas.contains(clientId))
        {
View Full Code Here

TOP

Related Classes of org.richfaces.component.UISuggestionBox

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.