Package org.openfaces.component.select

Examples of org.openfaces.component.select.SelectOneRadio


* @author Oleg Marshalenko
*/
public class SelectOneRadioRenderer extends SelectManyInputRenderer {

    protected void renderWithImages(FacesContext facesContext, ResponseWriter writer, OUISelectManyInputBase selectManyInputBase, List<SelectItem> selectItems, boolean isLineLayout) throws IOException {
        SelectOneRadio selectOneRadio = (SelectOneRadio) selectManyInputBase;
        String clientId = selectOneRadio.getClientId(facesContext);

        if (isLineLayout) {
            writer.startElement("tr", selectOneRadio);
        }

        for (int i = 0; i < selectItems.size(); i++) {
            SelectItem selectItem = selectItems.get(i);

            if (!isLineLayout) {
                writer.startElement("tr", selectOneRadio);
            }
            writer.startElement("td", selectOneRadio);

            String id = getIdIndexed(clientId, i);

            String imageId = id + IMAGE_SUFFIX;

            writer.startElement(TAG_NAME, selectManyInputBase);
            writeAttribute(writer, "id", imageId);
            writeAttribute(writer, "type", "image");
            writeAttribute(writer, "src", getCurrentImageUrl(facesContext, selectOneRadio, selectItem));
            writeCommonAttributes(writer, selectOneRadio, selectItem);
            writer.endElement(TAG_NAME);

            writer.startElement(TAG_NAME, selectOneRadio);
            writeAttribute(writer, "id", id);
            writeAttribute(writer, "name", clientId);
            writeAttribute(writer, "type", "radio");

            writeAttribute(writer, "value", getFormattedValue(selectOneRadio, selectItem.getValue()));
            writeAttribute(writer, "style", "display: none;");

            if (selectOneRadio.isDisabled() || selectItem.isDisabled()) {
                writeAttribute(writer, "disabled", "disabled");
            }
            if (isValueEquals(selectOneRadio, selectItem)) {
                writeAttribute(writer, "checked", "checked");
            }
View Full Code Here


            }
        }
    }

    protected void renderWithHtmlElements(FacesContext facesContext, ResponseWriter writer, OUISelectManyInputBase selectManyInputBase, List<SelectItem> selectItems, boolean isLineLayout) throws IOException {
        SelectOneRadio selectOneRadio = (SelectOneRadio) selectManyInputBase;
        String clientId = selectOneRadio.getClientId(facesContext);

        if (isLineLayout) {
            writer.startElement("tr", selectOneRadio);
        }

        for (int i = 0; i < selectItems.size(); i++) {
            SelectItem selectItem = selectItems.get(i);

            if (!isLineLayout) {
                writer.startElement("tr", selectOneRadio);
            }
            writer.startElement("td", selectOneRadio);

            String id = getIdIndexed(clientId, i);
            writer.startElement(TAG_NAME, selectOneRadio);
            writeAttribute(writer, "id", id);
            writeAttribute(writer, "name", clientId);
            writeAttribute(writer, "type", "radio");
            writeAttribute(writer, "value", getFormattedValue(selectOneRadio, selectItem.getValue()));
            writeCommonAttributes(writer, selectOneRadio, selectItem);
            if (selectOneRadio.isDisabled() || selectItem.isDisabled()) {
                writeAttribute(writer, "disabled", "disabled");
            }
            if (isValueEquals(selectOneRadio, selectItem)) {
                writeAttribute(writer, "checked", "checked");
            }
            writeAttribute(writer, "onchange", selectOneRadio.getOnchange());
            writer.endElement(TAG_NAME);

            writer.startElement("label", selectOneRadio);
            String labelId = id + LABEL_SUFFIX;
            writeAttribute(writer, "id", labelId);
View Full Code Here

        }
    }

    @Override
    public void decode(FacesContext context, UIComponent component) {
        SelectOneRadio selectOneRadio = (SelectOneRadio) component;

        Map<String, String> requestMap = context.getExternalContext().getRequestParameterMap();

        String clientId = selectOneRadio.getClientId(context);

        if (requestMap.containsKey(clientId)) {
            String requestValue = requestMap.get(clientId);
            selectOneRadio.setSubmittedValue(requestValue);
        }
    }
View Full Code Here

    }

    protected void renderInitScript(FacesContext facesContext, OUISelectManyInputBase selectManyInputBase,
                                    JSONObject imagesObj, JSONObject stylesObj, int selectItemCount, AnonymousFunction onchangeFunction)
            throws IOException {
        SelectOneRadio selectOneRadio = (SelectOneRadio) selectManyInputBase;
        Script initScript = new ScriptBuilder().initScript(facesContext, selectOneRadio, "O$.Radio._init",
                imagesObj,
                stylesObj,
                selectItemCount,
                selectOneRadio.isDisabled(),
                selectOneRadio.isReadonly(),
                onchangeFunction
        );

        Rendering.renderInitScript(facesContext, initScript,
                Resources.utilJsURL(facesContext),
View Full Code Here

TOP

Related Classes of org.openfaces.component.select.SelectOneRadio

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.