Search in sources :

Example 1 with HtmlSelectOneRadio

use of javax.faces.component.html.HtmlSelectOneRadio in project empire-db by apache.

the class RadioInputControl method createInputComponents.

@Override
protected void createInputComponents(UIComponent parent, InputInfo ii, FacesContext context, List<UIComponent> compList) {
    if (!compList.isEmpty())
        throw new InvalidArgumentException("compList", compList);
    // create
    HtmlSelectOneRadio input = InputControlManager.createComponent(context, this.inputComponentClass);
    // setValueExpressionFlag
    Object value = ii.getValue(false);
    input.getAttributes().put(RadioInputControl.VALUE_EXPRESSION_FLAG, (value instanceof ValueExpression));
    // copy Attributes
    copyAttributes(parent, ii, input);
    // disabled
    boolean disabled = ii.isDisabled();
    input.setDisabled(disabled);
    // Options
    Options options = ii.getOptions();
    boolean addEmpty = getEmptyEntryRequired(ii, disabled) && !options.containsNull();
    String nullText = (addEmpty) ? getNullText(ii) : "";
    initOptions(input, ii.getTextResolver(), options, addEmpty, nullText);
    // add
    compList.add(input);
    // style
    addRemoveDisabledStyle(input, disabled);
    addRemoveInvalidStyle(input, ii.hasError());
    // Set Value
    setInputValue(input, ii);
}
Also used : Options(org.apache.empire.commons.Options) InvalidArgumentException(org.apache.empire.exceptions.InvalidArgumentException) ValueExpression(javax.el.ValueExpression) HtmlSelectOneRadio(javax.faces.component.html.HtmlSelectOneRadio)

Example 2 with HtmlSelectOneRadio

use of javax.faces.component.html.HtmlSelectOneRadio in project empire-db by apache.

the class RadioInputControl method updateInputState.

@Override
protected void updateInputState(List<UIComponent> compList, InputInfo ii, FacesContext context, PhaseId phaseId) {
    UIComponent comp = compList.get(0);
    if (!(comp instanceof HtmlSelectOneRadio)) {
        throw new UnexpectedReturnValueException(comp.getClass().getName(), "parent.getChildren()");
    }
    HtmlSelectOneRadio input = (HtmlSelectOneRadio) comp;
    // disabled
    boolean disabled = ii.isDisabled();
    input.setDisabled(disabled);
    // check phase
    if (phaseId != PhaseId.APPLY_REQUEST_VALUES) {
        // Options (sync)
        Options options = ii.getOptions();
        boolean addEmpty = getEmptyEntryRequired(ii, disabled) && !options.containsNull();
        String nullText = (addEmpty) ? getNullText(ii) : "";
        syncOptions(input, ii.getTextResolver(), options, addEmpty, nullText);
    }
    if (phaseId == PhaseId.RENDER_RESPONSE) {
        // style
        addRemoveDisabledStyle(input, disabled);
        addRemoveInvalidStyle(input, ii.hasError());
        // set value
        setInputValue(input, ii);
    }
}
Also used : Options(org.apache.empire.commons.Options) UnexpectedReturnValueException(org.apache.empire.exceptions.UnexpectedReturnValueException) UIComponent(javax.faces.component.UIComponent) HtmlSelectOneRadio(javax.faces.component.html.HtmlSelectOneRadio)

Example 3 with HtmlSelectOneRadio

use of javax.faces.component.html.HtmlSelectOneRadio in project TNTConcept by autentia.

the class ActivityBean method getRolesBySelectedProject.

public List<SelectItem> getRolesBySelectedProject() {
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    ProjectRoleSearch prjRolSearch = new ProjectRoleSearch();
    prjRolSearch.setProject(getSelectedProject());
    List<ProjectRole> refs = ProjectRoleManager.getDefault().getAllEntities(prjRolSearch, new SortCriteria("name", false));
    if (refs != null) {
        for (ProjectRole ref : refs) {
            ret.add(new SelectItem(ref, ref.getName()));
        }
        // proyecto, por que sino borrariamos y creariamos una situaciĆ³n inconsistente
        if (this.getRole() != null && this.getRole().getProject() != null && !this.getRole().getProject().equals(this.getSelectedProject())) {
            HtmlSelectOneRadio optRole = (HtmlSelectOneRadio) FacesUtils.getComponent("activity").findComponent("tabActivity").findComponent("role");
            this.setRole(refs.get(0));
            optRole.setValue(this.getRole());
        }
    }
    return ret;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList) ProjectRoleSearch(com.autentia.tnt.dao.search.ProjectRoleSearch) ProjectRole(com.autentia.tnt.businessobject.ProjectRole) HtmlSelectOneRadio(javax.faces.component.html.HtmlSelectOneRadio)

Aggregations

HtmlSelectOneRadio (javax.faces.component.html.HtmlSelectOneRadio)3 Options (org.apache.empire.commons.Options)2 ProjectRole (com.autentia.tnt.businessobject.ProjectRole)1 SortCriteria (com.autentia.tnt.dao.SortCriteria)1 ProjectRoleSearch (com.autentia.tnt.dao.search.ProjectRoleSearch)1 ArrayList (java.util.ArrayList)1 ValueExpression (javax.el.ValueExpression)1 UIComponent (javax.faces.component.UIComponent)1 SelectItem (javax.faces.model.SelectItem)1 InvalidArgumentException (org.apache.empire.exceptions.InvalidArgumentException)1 UnexpectedReturnValueException (org.apache.empire.exceptions.UnexpectedReturnValueException)1