2
  • I have added a ui:repeat within a ul-list to produce a unordered list
  • Through jQuery Tag-It widget the list get´s nicely editable (unfortunately primefaces doen't have a similar component yet)
  • when saving the form i can't access the new created values (only the values of the other primefaces components)

XHTML

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

Bean

public class Bean implements Serializable {
    private MyObject selectedObject;
}

Model

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

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

Any idea, how i can access the values which are added to the UL-List? Thanks!

EDIT: The bean is session scoped

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
jimmybondy
  • 2,092
  • 3
  • 21
  • 33

1 Answers1

1

According to its documentation and demos the jQuery tag-it plugin autocreates a hidden input element with the (configureable) name syntax item[tags][]. You should be able to grab it from the HTTP request parameter values map by ExternalContext#getRequestParameterValuesMap() in JSF as follows:

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

You could also set it as a managed property, but this requires the bean to be request scoped.

@ManagedProperty("#{paramValues['item[tags][]']}")
private String[] tags;
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Hi BalusC, awesome! It works. Actually i was just reading your [answer to ui:repeat and h:panelGrid](http://stackoverflow.com/questions/8945544/uirepeat-and-hpanelgrid) and i thought my requirement is not going to work as `` is a render time tag, but obviously i misunderstood. BTW: What about creating a component like TagIt to [OmniFaces](https://showcase-omnifaces.rhcloud.com/)? ;-) – jimmybondy Jun 06 '12 at 18:38
  • It's by the way already been requested 5 hours earlier today: http://code.google.com/p/primefaces/issues/detail?id=4166&q=%22new%20component%22&colspec=ID%20Stars%20Type%20Status%20Priority%20TargetVersion%20Reporter%20Owner%20Summary Was it you? – BalusC Jun 06 '12 at 18:51
  • Voted! And actually i already posted a [feature request to PF](http://code.google.com/p/primefaces/issues/detail?id=4166) – jimmybondy Jun 06 '12 at 18:52