Stop generation tables and fieldset tag in output of Check box / Radio button Group control

青春壹個敷衍的年華 提交于 2019-12-19 10:53:14

问题


When using a checkbox group XPage generates fieldset and table tags around it. Is there a way to not generate that? For e.g. if my XPage source looks like this -

<xp:checkBoxGroup id="checkBoxGroup" disableTheme="true" value="#{document1.CheckboxGroup}">
    <xp:selectItems>
        <xp:this.value><![CDATA[#{javascript:new Array("Option 1", "Option 2", "Option 3");}]]></xp:this.value>
    </xp:selectItems>
</xp:checkBoxGroup>

Then my generated code is

<fieldset id="view:_id1:checkBoxGroup">
    <table>
        <tr>
            <td>
                <label><input name="view:_id1:checkBoxGroup" value="Option 1" type="checkbox"> Option 1</input></label>
            </td>
            <td>
                <label><input name="view:_id1:checkBoxGroup" value="Option 2" type="checkbox"> Option 2</input></label>
            </td>
            <td>
                <label><input name="view:_id1:checkBoxGroup" value="Option 3" type="checkbox"> Option 3</input></label>
            </td>
        </tr>
    </table>
</fieldset>

That's a lot of code for three checkboxes. And it messes up my CSS as putting any CSS for table tag puts it on the checkbox group also. The also goes for radio button group. I tried setting disableTheme property to true but that also didn't work.


回答1:


If you want to fundamentally change the structure of the HTML representation of a component, you can use the Extensibility API to create an alternate renderer. This allows you full control over what markup is sent to the browser for a specific component instance without changing how any other components are rendered. Register the renderer with the same component-family as the default renderer (javax.faces.SelectMany), but assign it a custom renderer-type; if you then assign that custom value to the rendererType property of a specific checkbox group, Domino will use your custom renderer class to emit the HTML instead of the default renderer class.




回答2:


You can also use the xp:radio control instead of the xp:radioGroup control and then group several radio buttons using the groupName property. Radio buttons rendered from xp:radio are not surrounded with fieldset and table.



来源:https://stackoverflow.com/questions/13973812/stop-generation-tables-and-fieldset-tag-in-output-of-check-box-radio-button-gr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!