问题
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