2010-08-10 91 views
1

我們使用h:selectManyCheckboxh:selectOneRadio來針對某個元素進行渲染選擇。我們希望能夠靈活地佈置水平,垂直或按多列排序的選擇。如何更改單選按鈕或複選框佈局

e.g. 
1. Horizontally 
one two three four five six 

2. Vertically 
one 
two 
three 
four 
five 
six 

3. 2 columns 
one two 
three four 
five six 

4. 3 columns 
one two three 
four five six 

我們如何使用現有的jsf標籤或通過適當的更改來實現這一點。

+0

我覺得自定義JSF UI組件或自定義JSP標記是一個解決方案... – 2010-08-10 03:37:56

+0

格式化文本,使其更清晰 – user339108 2010-08-10 03:47:40

+0

爲第一和第二個問題,您可以使用佈局屬性,如佈局=「lineDirection」或這些jsf標籤中的layout =「pageDirection」。 – khairil 2010-08-10 04:04:32

回答

0
  1. 首先,是清楚你要什麼...
  2. 看看:Developing a custom JSF tag
  3. 知道什麼屬性,你可以在你的新的自定義代碼傳遞,例如(<h:customRadioButtons list="arraylist" style="table" name="rbuttons" columns="2" />
  4. 你下發展未來customTag ...
2

你可以嘗試從apache tomahawk庫中使用layoutWidth屬性。或創建自己的JSF組件

+1

使用Tomahawk的't:selectOneRadio'與'layoutWidth'屬性是答案。 – BalusC 2010-08-10 11:18:03

-2

您可以facelate,這和使用,幷包含ID,值,檢查爲myBean綁定自定義佈局....

0

使用戰斧,我們可以嘗試使用佈局=」傳播」,如:

<t:selectOneRadio id="test" value="one" layout="spread" border="1"> 
    <f:selectItem itemLabel="one" itemValue="one" /> 
    <f:selectItem itemLabel="two" itemValue="two" /> 
    <f:selectItem itemLabel="three" itemValue="three" /> 
    <f:selectItem itemLabel="four" itemValue="four" /> 
    <f:selectItem itemLabel="five" itemValue="five" />  
    </t:selectOneRadio> 
    <t:panelGrid columns="2"> 
    <t:radio for="test" index="0"></t:radio> 
    <t:radio for="test" index="1"></t:radio> 
    </t:panelGrid> 
    <t:panelGrid columns="3"> 
    <t:radio for="test" index="2"></t:radio>     
    <t:radio for="test" index="3"></t:radio> 
    <t:radio for="test" index="4"></t:radio> 
    </t:panelGrid> 

然後使用AJAX重新呈現這件T:selectOneRadio更改爲其他佈局。

+0

我們不使用tomahawk,我們使用richfaces和Mojarra(Sun的RI) – user339108 2010-08-11 04:16:44