Primefaces tabView: embed text near title attribute of p:tab
Perhaps,somebody faced such a problem,looks like specific one and concerning Primefaces tabView
componen开发者_如何学JAVAt.
How is it possible to embed text if <p:tab>
generated dynamically and contains a lot of HTML sub-elements (ul
, li
etc.)?
Thank you for help.
You can add output in the tab title.
<p:tab title="Comments #{myBean.number}">
</p:tab>
Bean would look something like this:
@ManagedBean
@ViewScoped
public class MyBean implements Serializable {
private int number;
public MyBean() {
this.number = 5;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public void addComment() {
setNumber(number + 1);
}
}
Update Comments total with ajax:
<h:form>
<p:tabView id="tabs">
<p:tab title="Comments #{myBean.number}" >
<p:commandButton value="Add Comment"
action="#{myBean.addComment}" update="tabs"/>
</p:tab>
<p:tab title="tab" ></p:tab>
</p:tabView>
</h:form>
I couldn't get update to work correctly on the tab level but updating the entire tabView works.
精彩评论