javax.faces.component.UIInput Java Examples

The following examples show how to use javax.faces.component.UIInput. 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: InputDateRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
private boolean isUsingInputPlainText(FacesContext context, UIInput component) {
    
    // most browsers use <input type=datetime, but for iOS defaulting to type=text
    boolean isUseInputPlainTextOnIOS = true;
    String option = ((FacesContextEx)context).getProperty("xsp.theme.mobile.iOS.native.dateTime"); //$NON-NLS-1$
    if( null != option ){
        // explicitly configured whether to use type=datetime on iOS
        boolean isNativeOnIOS = "true".equals(option); //$NON-NLS-1$
        isUseInputPlainTextOnIOS = ! isNativeOnIOS;
    }
    if( isUseInputPlainTextOnIOS ){
        Object deviceBeanObj = ExtLibUtil.resolveVariable(context, "deviceBean"); //$NON-NLS-1$
        if( deviceBeanObj instanceof DeviceBean ){
            DeviceBean deviceBean = (DeviceBean)deviceBeanObj;
            boolean isIOS = deviceBean.isIphone()|| deviceBean.isIpad() || deviceBean.isIpod();
            if( isIOS ){
                // is iOS, so by use type=text
                return true;
            }
            // else other devices use type=datetime, not type=text
        }
    }
    // else always use type=datetime, don't need to whether check browser OS is iOS.
    return false;
}
 
Example #2
Source File: MobileTypeAheadInputRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
private void initTypeAhead(FacesContext context, UIInput input, XspTypeAhead typeAhead) {
    
    // prevent setParent after restoreState from overwriting the rendererType set in the theme file
    String themeConfiguredInputRendererType = input.getRendererType();
    typeAhead.setParentRendererType(themeConfiguredInputRendererType);
    
    // TODO have to do this overriding here instead of in the theme file
    // because XspTypeAhead doesn't implement ThemeControl
    String existingDojoType = typeAhead.getDojoType();
    if( null == existingDojoType ){
        String dojoType= COMBOBOX_MODULE.getName();
        typeAhead.setDojoType(dojoType);
    }
    
    String existingStoreType = typeAhead.getDojoStoreType();
    if( null == existingStoreType ){
        String storeType = "extlib.store.TypeAheadStore"; //$NON-NLS-1$
        typeAhead.setDojoStoreType(storeType);
    }
}
 
Example #3
Source File: JSFUtils.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * Reset the values of all UIInput children. This might be necessary after a
 * validation error to successfully process an AJAX request. See [Bug 5449]
 * and http://wiki.apache.org/myfaces/ClearInputComponents
 * 
 * @param uiComponent
 *            the root component to be processed.
 */
public static void resetUIInputChildren(UIComponent uiComponent) {
    if (uiComponent != null) {
        List<UIComponent> children = uiComponent.getChildren();
        for (UIComponent child : children) {
            if (child instanceof UIInput) {
                UIInput uiInput = (UIInput) child;
                uiInput.setSubmittedValue(null);
                uiInput.setValue(null);
                uiInput.setLocalValueSet(false);
            } else {
                resetUIInputChildren(child);
            }
        }
    }
}
 
Example #4
Source File: SubscriptionWizardConversationTest.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void testValidateSubscriptionId() throws Exception {

    // given
    SubscriptionServiceInternal ssi = mock(SubscriptionServiceInternal.class);
    doReturn(true).when(ssi).validateSubscriptionIdForOrganization(
            anyString());
    doReturn(ssi).when(bean).getSubscriptionServiceInternal();

    UIComponent uiInputMock = mock(UIInput.class);
    FacesContext contextMock = mock(FacesContext.class);

    // when
    bean.validateSubscriptionId(contextMock, uiInputMock, "value");

    // then
    verify(ui, times(1)).handleError(anyString(),
            eq(SUBSCRIPTION_NAME_ALREADY_EXISTS), anyObject());
}
 
Example #5
Source File: MobileFormTableRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void writeFormRow(FacesContext context, ResponseWriter w, FormLayout c, ComputedFormData formData, UIFormLayoutRow row) throws IOException {
    ComputedRowData rowData = createRowData(context, c, formData, row);

    UIInput edit = row.getForComponent();
    if(edit!=null) {
        // Write the error messages, if any
        if(!formData.isDisableRowError()) {
            Iterator<FacesMessage> msg = ((DominoFacesContext)context).getMessages(edit.getClientId(context));
            if(msg.hasNext()) {
                while(msg.hasNext()) {
                    FacesMessage m = msg.next();
                    writeFormRowError(context, w, c, row, edit, m, rowData);
                }
            }
        }
    }
    
    // The write the children
    writeFormRowData(context, w, c, formData, row, edit, rowData);
}
 
Example #6
Source File: ColorPickerRenderer.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * decode method
 * @param context
 * @param component
 */
public void decode(FacesContext context, UIComponent component)
{
  // we haven't added these attributes--yet--defensive programming...
  if(RendererUtil.isDisabledOrReadonly(component))
  {
    return;
  }

  String clientId = component.getClientId(context);
  Map requestParameterMap = context.getExternalContext()
                            .getRequestParameterMap();
  String newValue = (String) requestParameterMap.get(clientId );
  UIInput comp = (UIInput) component;
  comp.setSubmittedValue(newValue);
}
 
Example #7
Source File: DojoToggleButtonRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void writeValueAttribute(FacesContext context, UIInput component, ResponseWriter writer, String currentValue) throws IOException {
    UIDojoToggleButton ck = (UIDojoToggleButton)component;
    Object oCheckedValue = ck.getCheckedValue();
    String checkedValue = null;
    if (oCheckedValue != null) {
    	checkedValue = oCheckedValue.toString();
    }
    if(checkedValue==null) {
        checkedValue = UIDojoCheckBox.CHECKED_VALUE_DEFAULT;
    }
    if(StringUtil.equals(checkedValue, currentValue)) {
        // Should it be a dojo attribute instead?
        writer.writeAttribute("value", "on", null); //$NON-NLS-1$ //$NON-NLS-2$
    }
}
 
Example #8
Source File: InputColorRenderer.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * decode method
 * @param context
 * @param component
 */
public void decode(FacesContext context, UIComponent component)
{
  // we haven't added these attributes--yet--defensive programming...
  if(RendererUtil.isDisabledOrReadonly(context, component))
  {
    return;
  }

  String clientId = component.getClientId(context);
  Map requestParameterMap = context.getExternalContext()
                            .getRequestParameterMap();
  String newValue = (String) requestParameterMap.get(clientId );
  UIInput comp = (UIInput) component;
  comp.setSubmittedValue(newValue);
}
 
Example #9
Source File: FormLayoutRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
protected void writeFormRowDataHelp(FacesContext context, ResponseWriter w, FormLayout c, UIFormLayoutRow row, UIInput edit, String helpId) throws IOException {
    // TODO: how should the help be implemented?
    w.startElement("a", c);
    w.writeAttribute("href", "javascript:;", null); // $NON-NLS-1$ $NON-NLS-2$
    w.writeAttribute("aria-haspopup", "true", null); // $NON-NLS-1$ $NON-NLS-2$
    w.writeAttribute("aria-owns", helpId, null); // $NON-NLS-1$
    w.startElement("img", c); // $NON-NLS-1$
    String style = (String)getProperty(PROP_HELPIMGSTYLE);
    if(StringUtil.isNotEmpty(style)) {
        w.writeAttribute("style", style, null); // $NON-NLS-1$
    }
    String cls = (String)getProperty(PROP_HELPIMGCLASS);
    if(StringUtil.isNotEmpty(cls)) {
        w.writeAttribute("class", cls, null); // $NON-NLS-1$
    }
    String bgif = (String)getProperty(PROP_HELPIMGSRC);
    if(StringUtil.isNotEmpty(bgif)) {
        w.writeAttribute("src",HtmlRendererUtil.getImageURL(context,bgif),null); // $NON-NLS-1$
    }
    String alt = (String)getProperty(PROP_HELPIMGALT);
    if(StringUtil.isNotEmpty(alt)) {
        w.writeAttribute("alt", alt, null); // $NON-NLS-1$
    }
    w.endElement("img"); // $NON-NLS-1$
    w.endElement("a");
}
 
Example #10
Source File: FormTableRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
protected void writeFormRow(FacesContext context, ResponseWriter w, FormLayout c, ComputedFormData formData, UIFormLayoutRow row) throws IOException {
    
    ComputedRowData rowData = createRowData(context, c, formData, row);

    UIInput edit = row.getForComponent();
    if(edit!=null) {
        // Write the error messages, if any
        if(!formData.isDisableRowError()) {
            Iterator<FacesMessage> msg = getMessages(context, edit.getClientId(context));
            if(msg.hasNext()) {
                while(msg.hasNext()) {
                    FacesMessage m = msg.next();
                    writeFormRowError(context, w, c, row, edit, m, rowData);
                }
            }
        }
    }
    
    // The write the children
    writeFormRowData(context, w, c, formData, row, edit, rowData);
}
 
Example #11
Source File: ConfigureCacheRefreshAction.java    From oxTrust with MIT License 6 votes vote down vote up
public void validateProperty(FacesContext context, UIComponent comp, Object value) {
	String newkeyAttr = (String) value;
	oxTrustAuditService.audit("Validation");
	for (SimpleProperty keyAttribute : keyAttributes) {
		int i = 0;
		if (newkeyAttr.equalsIgnoreCase(keyAttribute.getValue())) {
			i = i + 1;
			if (i == 2) {
				((UIInput) comp).setValid(false);
				FacesMessage message = new FacesMessage("key attribute already Exist! ");
				context.addMessage(comp.getClientId(context), message);
			}
		}

	}
}
 
Example #12
Source File: ColorPickerRenderer.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * decode method
 * @param context
 * @param component
 */
public void decode(FacesContext context, UIComponent component)
{
  // we haven't added these attributes--yet--defensive programming...
  if(RendererUtil.isDisabledOrReadonly(component))
  {
    return;
  }

  String clientId = component.getClientId(context);
  Map requestParameterMap = context.getExternalContext()
                            .getRequestParameterMap();
  String newValue = (String) requestParameterMap.get(clientId );
  UIInput comp = (UIInput) component;
  comp.setSubmittedValue(newValue);
}
 
Example #13
Source File: CoreRenderer.java    From BootsFaces-OSP with Apache License 2.0 6 votes vote down vote up
/**
 * Renders the CSS pseudo classes for required fields and for the error levels.
 *
 * @param input
 * @param rw
 * @param clientId
 * @throws IOException
 */
protected void generateErrorAndRequiredClass(UIInput input, ResponseWriter rw, String clientId,
		String additionalClass1, String additionalClass2, String additionalClass3) throws IOException {
	String styleClass = getErrorAndRequiredClass(input, clientId);
	if (null != additionalClass1) {
		additionalClass1 = additionalClass1.trim();
		if (additionalClass1.trim().length() > 0) {
			styleClass += " " + additionalClass1;
		}
	}
	if (null != additionalClass2) {
		additionalClass2 = additionalClass2.trim();
		if (additionalClass2.trim().length() > 0) {
			styleClass += " " + additionalClass2;
		}
	}
	if (null != additionalClass3) {
		additionalClass3 = additionalClass3.trim();
		if (additionalClass3.trim().length() > 0) {
			styleClass += " " + additionalClass3;
		}
	}
	rw.writeAttribute("class", styleClass, "class");
}
 
Example #14
Source File: FormTableRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void writeFormRowHelp(FacesContext context, ResponseWriter w, FormLayout c, UIFormLayoutRow row, UIInput edit) throws IOException {
    String helpId = row.getHelpId();
    String helpStyle = (String)getProperty(PROP_HELPROWSTYLE);
    if(StringUtil.isNotEmpty(helpStyle)) {
        w.writeAttribute("style", helpStyle, null); // $NON-NLS-1$
    }
    if(StringUtil.isNotEmpty(helpId)) {
        String forClientId = null;
        UIComponent forComponent = FacesUtil.getComponentFor(c, helpId);
        if(forComponent == null) {
            UIComponent p = (UIComponent)FacesUtil.getNamingContainer(c);
            if(p!=null) {
               forClientId = p.getClientId(context)+":"+helpId;
            }
        } else {
            forClientId = forComponent.getClientId(context);
        }
        writeFormRowDataHelp(context, w, c, row, edit, forClientId);
    } else {
        UIComponent facet = row.getFacet(UIFormLayoutRow.FACET_HELP);
        if(facet!=null) {
            writeFormRowDataHelpFacet(context, w, c, row, edit, facet);
        }
    }
}
 
Example #15
Source File: CoreRenderer.java    From BootsFaces-OSP with Apache License 2.0 6 votes vote down vote up
/**
 * @deprecated Use
 *             {@link CoreRenderer#generateErrorAndRequiredClass(javax.faces.component.UIInput, javax.faces.context.ResponseWriter, java.lang.String, java.lang.String, java.lang.String, java.lang.String) }
 *             instead
 * 
 *             Renders the CSS pseudo classes for required fields and for the
 *             error levels.
 *
 * @param input
 * @param rw
 * @param clientId
 * @throws IOException
 */
@Deprecated
public void generateErrorAndRequiredClassForLabels(UIInput input, ResponseWriter rw, String clientId,
		String additionalClass) throws IOException {
	String styleClass = getErrorAndRequiredClass(input, clientId);
	if (null != additionalClass) {
		additionalClass = additionalClass.trim();
		if (additionalClass.trim().length() > 0) {
			styleClass += " " + additionalClass;
		}
	}
	UIForm currentForm = AJAXRenderer.getSurroundingForm((UIComponent) input, true);
	if (currentForm instanceof Form) {
		if (((Form) currentForm).isHorizontal()) {
			styleClass += " control-label";
		}
	}
	if (input instanceof IResponsiveLabel) {
		String responsiveLabelClass = Responsive.getResponsiveLabelClass((IResponsiveLabel) input);
		if (null != responsiveLabelClass) {
			styleClass += " " + responsiveLabelClass;
		}
	}

	rw.writeAttribute("class", styleClass, "class");
}
 
Example #16
Source File: MobileTypeAheadInputRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
    
    Map<String, Object> attrs = TypedUtil.getAttributes(component);
    String initializedKey = "_initialized_MobileTypeAheadInputRenderer"; //$NON-NLS-1$
    if( null == attrs.get(initializedKey) ){
        UIInput input = (UIInput) component;
        XspTypeAhead typeAhead = findTypeAheadChild(input);
        if( null != typeAhead && typeAhead.isTypeAheadEnabled(context)){
            initTypeAhead(context, input, typeAhead);
            validateNoSeparator(context, input, typeAhead);
        }
        attrs.put(initializedKey, "true"); //$NON-NLS-1$ //$NON-NLS-2$
    }
    
    super.encodeBegin(context, component);
}
 
Example #17
Source File: FormTableRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void writeFormRowHelp(FacesContext context, ResponseWriter w, FormLayout c, UIFormLayoutRow row, UIInput edit) throws IOException {
    String helpId = row.getHelpId();
    String helpStyle = (String)getProperty(PROP_HELPROWSTYLE);
    if(StringUtil.isNotEmpty(helpStyle)) {
        w.writeAttribute("style", helpStyle, null); // $NON-NLS-1$
    }
    String helpClass = (String)getProperty(PROP_HELPROWCLASS);
    if(StringUtil.isNotEmpty(helpClass)) {
        w.writeAttribute("class", helpClass, null); // $NON-NLS-1$
    }
    if(StringUtil.isNotEmpty(helpId)) {
        String forClientId = null;
        UIComponent forComponent = FacesUtil.getComponentFor(c, helpId);
        if(forComponent == null) {
            UIComponent p = (UIComponent)FacesUtil.getNamingContainer(c);
            if(p!=null) {
               forClientId = p.getClientId(context)+":"+helpId;
            }
        } else {
            forClientId = forComponent.getClientId(context);
        }
        writeFormRowDataHelp(context, w, c, row, edit, forClientId);
    } else {
        UIComponent facet = row.getFacet(UIFormLayoutRow.FACET_HELP);
        if(facet!=null) {
            writeFormRowDataHelpFacet(context, w, c, row, edit, facet);
        } else {
            JSUtil.writeTextBlank(w); // &nbsp;
        }
    }
}
 
Example #18
Source File: FormLayoutRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void writeFormRowRequiredContent(FacesContext context, ResponseWriter w, FormLayout c, UIFormLayoutRow row, UIInput edit) throws IOException {
	String reqClass = (String)getProperty(PROP_FIELDLABELREQUIREDCLASS);
	String reqText = (String)getProperty(PROP_FIELDLABELREQUIREDTEXT);
	if(StringUtil.isNotEmpty(reqClass) || StringUtil.isNotEmpty(reqText)) {
		w.startElement("span", c); // $NON-NLS-1$
		if(StringUtil.isNotEmpty(reqClass)) {
			w.writeAttribute("class", reqClass, null); // $NON-NLS-1$
		}
		if(StringUtil.isNotEmpty(reqText)) {
			w.writeText(reqText, null);
		}
		w.endElement("span"); // $NON-NLS-1$
	}
}
 
Example #19
Source File: DojoCheckBoxRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
protected void renderTagBody(FacesContext context, UIInput component, ResponseWriter writer, String currentValue) throws IOException {
    UIDojoCheckBox c = (UIDojoCheckBox)component;
    String label = c.getLabel();
    if(StringUtil.isNotEmpty(label)) {
        writer.startElement("label", c); //$NON-NLS-1$
        writer.writeAttribute("for", c.getClientId(context), null); //$NON-NLS-1$
        writer.writeText(label, "label"); //$NON-NLS-1$
        writer.endElement("label"); //$NON-NLS-1$
    }
}
 
Example #20
Source File: InputDateRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
private void encodeValidation(FacesContext context, ResponseWriter writer, UIInput uiInput) throws IOException {
    if(uiInput instanceof FacesInputComponent) {
        FacesInputComponent ic = (FacesInputComponent)uiInput;  
        // Write the client side validators
        RequestParameters p = FacesUtil.getRequestParameters(context);
        if(p.isClientSideValidation()) {
        	// Either the validators or only the client side validation can be disabled
        	if(!ic.isDisableValidators() && !ic.isDisableClientSideValidation()) {
        		generateClientSideValidation(context,uiInput,writer);
        	}
        }
    }
}
 
Example #21
Source File: DojoFormWidgetRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void startTag(FacesContext context, ResponseWriter writer, UIInput component) throws IOException {
    String tagName = getTagName();
    writer.startElement(tagName, component); //$NON-NLS-1$
    String type = getInputType();
    if(StringUtil.isNotEmpty(type)) {
        writer.writeAttribute("type", type, null); //$NON-NLS-1$ //$NON-NLS-2$
    }
}
 
Example #22
Source File: MobileTypeAheadInputRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
private void validateNoSeparator(FacesContext context, UIInput input, XspTypeAhead typeAhead) {
    boolean separatorDetected = false;
    String separatorType = null;
    if( null != typeAhead.getTokens() ){
        separatorDetected = true;
        separatorType = "xp:typeAhead tokens"; //$NON-NLS-1$
    }
    if( ! separatorDetected ){
        if( input instanceof UIInputEx){
            UIInputEx inputEx = (UIInputEx) input;
            String separator = inputEx.getMultipleSeparator();
            if( null != separator ){
                separatorDetected = true;
                separatorType = "xp:inputText multipleSeparator"; //$NON-NLS-1$
            }
        }
    }
    if( ! separatorDetected ){
        Converter converter = input.getConverter();
        if( converter instanceof ListConverter ){
            separatorDetected = true;
            separatorType = "xp:convertList"; //$NON-NLS-1$
        }
    }
    if( separatorDetected ){
        // String left untagged - hoping to support multiple before begin translating strings for next product release
        String msg = "The mobile xp:typeAhead control does not support entering multiple values in the edit box. A multiple value separator has been detected: {0}"; // $NLS-MobileTypeAheadInputRenderer.ThemobilexptypeAheadcontroldoesno-1$
        msg = StringUtil.format(msg, separatorType);
        throw new FacesExceptionEx(msg);
    }
}
 
Example #23
Source File: DojoComboBoxRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
protected void renderTagBody(FacesContext context, UIInput component, ResponseWriter writer, String currentValue) throws IOException {
    if(component instanceof UIDojoComboBox) {
        // Render the "options" portion if some children are available
        if(component.getChildCount()>0) {
            renderOptions(context, (UIDojoComboBox)component, writer, currentValue);
        }
    }
}
 
Example #24
Source File: Datepicker.java    From BootsFaces-OSP with Apache License 2.0 5 votes vote down vote up
/**
 * Yields the value of the required and error level CSS class.
 *
 * @param input
 * @param clientId
 * @return
 */
public String getErrorAndRequiredClass(UIInput input, String clientId) {
	String[] levels = { "bf-no-message", "bf-info", "bf-warning", "bf-error", "bf-fatal" };
	int level = 0;
	Iterator<FacesMessage> messages = FacesContext.getCurrentInstance().getMessages(clientId);
	if (null != messages) {
		while (messages.hasNext()) {
			FacesMessage message = messages.next();
			if (message.getSeverity().equals(FacesMessage.SEVERITY_INFO))
				if (level < 1)
					level = 1;
			if (message.getSeverity().equals(FacesMessage.SEVERITY_WARN))
				if (level < 2)
					level = 2;
			if (message.getSeverity().equals(FacesMessage.SEVERITY_ERROR))
				if (level < 3)
					level = 3;
			if (message.getSeverity().equals(FacesMessage.SEVERITY_FATAL))
				if (level < 4)
					level = 4;
		}
	}
	String styleClass = levels[level];
	if (input.isRequired()) {
		styleClass += " bf-required";
	}
	return styleClass;
}
 
Example #25
Source File: InputDateRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue)
    throws ConverterException {
    UIInput uiInput = (UIInput)component;
    DateTimeConverter converter = (DateTimeConverter) uiInput.getConverter();
    String value = (String)submittedValue;

    return getAsObject(context, uiInput, converter, value);
}
 
Example #26
Source File: InputDateRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
private int getValueType(UIInput uiInput) {
    DateTimeConverter converter = (DateTimeConverter) uiInput.getConverter();
    // Find what should be used: date, time or both
    // Default is both...
    String dateType = converter.getType();
    int type = TYPE_TIMESTAMP;
    if(StringUtil.isNotEmpty(dateType)) {
        if(dateType.equals(DateTimeConverter.TYPE_DATE)) {
            type = TYPE_DATE;
        } else if(dateType.equals(DateTimeConverter.TYPE_TIME)) {
            type = TYPE_TIME;
        }
    }
    return type;
}
 
Example #27
Source File: FormTableRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
protected void writeFormRow(FacesContext context, ResponseWriter w, FormLayout c, ComputedFormData formData, UIFormLayoutRow row) throws IOException {
    ComputedRowData rowData = createRowData(context, c, formData, row);
    UIInput edit = row.getForComponent();
    if(edit!=null) {
        // Write the error messages, if any
        if(!formData.isDisableRowError()) {
            String errorStyleClass = (String) getProperty(PROP_HASERRORSTYLECLASS);
            Iterator<FacesMessage> msg = getMessages(context, edit.getClientId(context));
            if(msg.hasNext()) {
                //Set the row styleClass to include bootstrap 'has-error' class
                row.setStyleClass(ExtLibUtil.concatStyleClasses(row.getStyleClass(), errorStyleClass));
                while(msg.hasNext()) {
                    FacesMessage m = msg.next();
                    writeFormRowError(context, w, c, row, edit, m, rowData);
                }
            }else{
                String rowStyleClass = row.getStyleClass();
                if(StringUtil.isNotEmpty(rowStyleClass) && rowStyleClass.contains(errorStyleClass)) {
                    row.setStyleClass(StringUtil.replace(rowStyleClass, errorStyleClass, ""));
                }
            }
        }
    }
    
    // Then write the children
    writeFormRowData(context, w, c, formData, row, edit, rowData);
}
 
Example #28
Source File: InputDateRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
private String computeValueAsISOString(FacesContext context, UIInput input) {
    DateTimeConverter converter = (DateTimeConverter) input.getConverter();
    
    // the submitted value takes precedence
    // As it is a string, no conversion should happen 
    Object submittedValue = input.getSubmittedValue();
    if (submittedValue != null) {
        return (String)submittedValue;
    }
    Object value = input.getValue();
    if( null == value ){
        return "";
    }
    return getAsString(context, input, converter, value);
}
 
Example #29
Source File: DojoRadioButtonRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
protected void writeValueAttribute(FacesContext context, UIInput component, ResponseWriter writer, String currentValue) throws IOException {
    UIDojoRadioButton rb = (UIDojoRadioButton)component;
    Object selectedObj = rb.getSelectedValue();
    if(selectedObj != null) {
        String selectedValue = selectedObj.toString();
        if(StringUtil.equals(selectedValue, currentValue)) {
            writer.writeAttribute("checked", "true", null); //$NON-NLS-1$ //$NON-NLS-2$
        }
        if(StringUtil.isNotEmpty(selectedValue)) {
            writer.writeAttribute("value", selectedValue, "selectedValue"); //$NON-NLS-1$ //$NON-NLS-2$
        }
    }
}
 
Example #30
Source File: SketchPadRenderer.java    From ctsms with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Converter getConverter(FacesContext context, UIComponent component) {
	Converter converter = ((UIInput) component).getConverter();
	if (converter != null) {
		return converter;
	}
	ValueExpression exp = component.getValueExpression("value");
	if (exp == null) {
		return null;
	}
	Class valueType = exp.getType(context.getELContext());
	if (valueType == null) {
		return null;
	}
	return context.getApplication().createConverter(valueType);
}