Search in sources :

Example 6 with HtmlOutputText

use of javax.faces.component.html.HtmlOutputText in project gdmatrix by gdmatrix.

the class QueryInstanceBean method addOperatorComponents.

private void addOperatorComponents(Operator operator, HtmlPanelGroup exprPanelGroup) {
    FacesContext context = FacesContext.getCurrentInstance();
    Application application = context.getApplication();
    ValueBinding valueBinding = context.getApplication().createValueBinding("expression #{queryInstanceBean.expressions['" + operator.getId() + "'].type}");
    exprPanelGroup.setValueBinding("styleClass", valueBinding);
    if (operator.getType().equals(Operator.ROOT)) {
        addLabelComponents(selectedInstance.getQuery().getLabel(), "selectedInstance.globalParameterValuesMap", selectedInstance.getQuery().getGlobalParameters(), exprPanelGroup);
    } else // other operators: and, or, nor
    {
        // add operator select box
        id++;
        HtmlSelectOneMenu selectMenu = new HtmlSelectOneMenu();
        selectMenu.setId(operator.getType() + "_" + id);
        selectMenu.setStyleClass("operator");
        selectMenu.setOnchange("submit();");
        String valueExpr = "#{queryInstanceBean.expressions['" + operator.getId() + "'].type}";
        valueBinding = context.getApplication().createValueBinding(valueExpr);
        selectMenu.setValueBinding("value", valueBinding);
        ArrayList list = new ArrayList();
        SelectItem item1 = new SelectItem();
        item1.setDescription(Operator.AND);
        item1.setValue(Operator.AND);
        item1.setLabel(getQueryLabel(Operator.AND));
        list.add(item1);
        SelectItem item2 = new SelectItem();
        item2.setDescription(Operator.OR);
        item2.setValue(Operator.OR);
        item2.setLabel(getQueryLabel(Operator.OR));
        list.add(item2);
        SelectItem item3 = new SelectItem();
        item3.setDescription(Operator.NOR);
        item3.setValue(Operator.NOR);
        item3.setLabel(getQueryLabel(Operator.NOR));
        list.add(item3);
        id++;
        UISelectItems selectItems = new UISelectItems();
        selectItems.setId("si_" + id);
        selectItems.setValue(list);
        selectMenu.getChildren().add(selectItems);
        exprPanelGroup.getChildren().add(selectMenu);
        id++;
        HtmlCommandButton button = new HtmlCommandButton();
        button.setId("button_" + id);
        MethodBinding method = application.createMethodBinding("#{queryInstanceBean.expressionWrappers['" + operator.getId() + "'].removeExpression}", new Class[0]);
        button.setAction(method);
        button.setImage("/common/misc/images/remove_expr.png");
        button.setStyleClass("expr_button remove");
        exprPanelGroup.getChildren().add(button);
    }
    id++;
    HtmlPanelGroup subPanelGroup = new HtmlPanelGroup();
    subPanelGroup.setId("comp_" + id);
    subPanelGroup.setStyleClass("op_children");
    exprPanelGroup.getChildren().add(subPanelGroup);
    for (Expression expr : operator.getArguments()) {
        addExpressionComponents(expr, subPanelGroup);
        if (!operator.getType().equals(Operator.ROOT)) {
            id++;
            HtmlOutputText linkText = new HtmlOutputText();
            linkText.setId("link_" + id);
            valueBinding = application.createValueBinding("#{queryInstanceBean.expressionWrappers['" + operator.getId() + "'].linkLabel}");
            linkText.setValueBinding("value", valueBinding);
            linkText.setStyleClass("operator_link");
            subPanelGroup.getChildren().add(linkText);
        }
    }
    if (operator.equals(selectedExpression)) {
        addExpressionList(context, subPanelGroup);
    } else {
        id++;
        HtmlCommandButton button = new HtmlCommandButton();
        button.setId("button_" + id);
        MethodBinding method = application.createMethodBinding("#{queryInstanceBean.expressionWrappers['" + operator.getId() + "'].selectExpression}", new Class[0]);
        button.setAction(method);
        button.setImage("/common/misc/images/add_expr.png");
        button.setStyleClass("expr_button add");
        ValueBinding value = application.createValueBinding("#{queryInstanceBean.expressionWrappers['" + operator.getId() + "'].addButtonRendered}");
        button.setValueBinding("rendered", value);
        subPanelGroup.getChildren().add(button);
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) UISelectItems(javax.faces.component.UISelectItems) ValueBinding(javax.faces.el.ValueBinding) ArrayList(java.util.ArrayList) HtmlSelectOneMenu(javax.faces.component.html.HtmlSelectOneMenu) HtmlCommandButton(javax.faces.component.html.HtmlCommandButton) Expression(org.santfeliu.misc.query.QueryInstance.Expression) SelectItem(javax.faces.model.SelectItem) MethodBinding(javax.faces.el.MethodBinding) HtmlPanelGroup(org.apache.myfaces.component.html.ext.HtmlPanelGroup) HtmlOutputText(javax.faces.component.html.HtmlOutputText) Application(javax.faces.application.Application)

Example 7 with HtmlOutputText

use of javax.faces.component.html.HtmlOutputText in project gdmatrix by gdmatrix.

the class WidgetTestBean method loadPanel.

private void loadPanel() {
    panel = new HtmlPanelGrid();
    panel.setId("panel_id");
    // Add output
    HtmlPanelGroup group = new HtmlPanelGroup();
    group.setId("group_id");
    HtmlOutputText output = new HtmlOutputText();
    output.setId("output_id");
    output.setValue("Hoy es: ");
    group.getChildren().add(output);
    HtmlCalendar cal = new HtmlCalendar();
    cal.setId("cal_id");
    cal.setValue(TextUtils.formatDate(new Date(), "dd/MM/yyyy"));
    group.getChildren().add(cal);
    panel.getChildren().add(group);
}
Also used : HtmlPanelGroup(javax.faces.component.html.HtmlPanelGroup) HtmlPanelGrid(javax.faces.component.html.HtmlPanelGrid) HtmlOutputText(javax.faces.component.html.HtmlOutputText) HtmlCalendar(org.santfeliu.faces.component.HtmlCalendar) Date(java.util.Date)

Example 8 with HtmlOutputText

use of javax.faces.component.html.HtmlOutputText in project ctsms by phoenixctms.

the class ColumnManagementBean method getColumnName.

private static String getColumnName(Column column) {
    String headerTextEl;
    UIComponent headerFacet = column.getFacet("header");
    try {
        // in general, columns have a header facet with p:outputText
        headerTextEl = ((HtmlOutputText) headerFacet).getValueExpression("value").getExpressionString();
    } catch (ClassCastException e) {
        // and there are columns with a dropdown in the header
        headerTextEl = ((HtmlPanelGroup) headerFacet).getChildren().get(0).getValueExpression("label").getExpressionString();
    }
    // Remove #{}
    return headerTextEl.substring(2, headerTextEl.length() - 1);
}
Also used : UIComponent(javax.faces.component.UIComponent) HtmlOutputText(javax.faces.component.html.HtmlOutputText)

Aggregations

HtmlOutputText (javax.faces.component.html.HtmlOutputText)8 Application (javax.faces.application.Application)3 HtmlPanelGroup (javax.faces.component.html.HtmlPanelGroup)3 UIParameter (javax.faces.component.UIParameter)2 HtmlAriaCommandLink (org.santfeliu.faces.component.HtmlAriaCommandLink)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 Locale (java.util.Locale)1 ResourceBundle (java.util.ResourceBundle)1 UIComponent (javax.faces.component.UIComponent)1 UIOutput (javax.faces.component.UIOutput)1 UISelectItems (javax.faces.component.UISelectItems)1 HtmlCommandButton (javax.faces.component.html.HtmlCommandButton)1 HtmlPanelGrid (javax.faces.component.html.HtmlPanelGrid)1 HtmlSelectOneMenu (javax.faces.component.html.HtmlSelectOneMenu)1 FacesContext (javax.faces.context.FacesContext)1 Converter (javax.faces.convert.Converter)1 DateTimeConverter (javax.faces.convert.DateTimeConverter)1 MethodBinding (javax.faces.el.MethodBinding)1