1

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.

Naveen
  • 6,786
  • 10
  • 37
  • 85

2 Answers2

3

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.

Tim Tripcony
  • 8,056
  • 1
  • 23
  • 34
  • I just went through the wiki you posted. So if I create custom renderer class and register it the `faces-config.xml` then I can use that class in `rendererType` property. Right? Please bear with me as I am new to extensiblility API. – Naveen Dec 20 '12 at 16:07
  • 1
    Correct. For instance, if in the faces-config you specify a custom renderer-type of "cssFriendlyCheckboxGroup", then on your XPage, set that same value in the rendererType attribute of your component, and it will use your Java class instead of the native one. – Tim Tripcony Dec 20 '12 at 16:29
  • Thanks Tim I was able to write my own output but to get options I writing this inside `encodeBegin` method `XspSelectManyCheckbox chk = (XspSelectManyCheckbox)component;List l = chk.getChildren();for (int i=0 ; i – Naveen Dec 22 '12 at 16:15
1

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.

Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76