2012-06-06 29 views
2
  • 我添加了一個界面:一個UL列表內重複產生無序列表
  • 通過jQuery Tag-It widget列表get's很好的編輯(不幸的是primefaces doen't具有類似的組分還)
  • 保存形式我不能訪問新創建的值(僅其他primefaces組件的值)

XHTML訪問通過增加內部UI jQuery UI的控件值:重複JSF

<ul id="keywordList"> 
<ui:repeat value="#{bean.selectedObject.keywords}" var="keyword"> 
    <li><h:outputText value="#{keyword.name}" /></li> 
    </ui:repeat> 
</ul> 

public class Bean implements Serializable { 
    private MyObject selectedObject; 
} 

型號

public List<String> getKeywords() { 
    return keywords; 
} 

public void setKeywords(List<String> keywords) { 
    this.keywords = keywords; 
} 

任何想法,我怎麼可以訪問哪些被添加到UL-列表中的值? 謝謝!

編輯:這個bean會話範圍

回答

1

據其documentationdemos jQuery的標籤,它的插件autocreates與(configureable)名語法item[tags][]一個隱藏的輸入元素。您應該能夠從HTTP請求參數抓住它通過ExternalContext#getRequestParameterValuesMap()在JSF值映射如下:

String[] tags = FacesContext.getCurrentInstance().getExternalContext() 
    .getRequestParameterValuesMap().get("item[tags][]"); 

你也可以把它作爲一個託管屬性,但這需要bean是請求範圍。

@ManagedProperty("#{paramValues['item[tags][]']}") 
private String[] tags; 
+0

Hi BalusC,太棒了!有用。其實我只是讀你的[回答ui:重複和h:panelGrid](http://stackoverflow.com/questions/8945544/uirepeat-and-hpanelgrid),我認爲我的要求不會作爲''是一個渲染時間標記,但顯然我誤解了。順便說一句:如何創建一個像TagIt組件到[OmniFaces](https://showcase-omnifaces.rhcloud.com/)? ;-) – jimmybondy

+0

今天早些時候5小時已經提出請求:http://code.google.com/p/primefaces/issues/detail?id=4166&q=%22new%20component%22&colspec=ID%20Stars%20Type %20Status%20Priority%20TargetVersion%20Reporter%20Owner%20Summary是你嗎? – BalusC

+0

已投票!實際上我已經發布了一個[功能請求PF](http://code.google.com/p/primefaces/issues/detail?id=4166) – jimmybondy