开发者

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.

There is tabbed view comments module and I would like to display comments number within tab,like this:

Primefaces tabView: embed text near title attribute of p:tab

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);        
  }

}

Primefaces tabView: embed text near title attribute of p:tab

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜