Frage

  • 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

War es hilfreich?

Lösung

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;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top