JSF2 - 以编程方式创建 HtmloutputLink
Posted
技术标签:
【中文标题】JSF2 - 以编程方式创建 HtmloutputLink【英文标题】:JSF2 - Create programmatically HtmloutputLink 【发布时间】:2014-05-19 20:39:34 【问题描述】:我想创建一组类似的输出链接
<li>
<h:outputLink value="#" styleClass="home">Home</h:outputLink>
<h:outputLink value="#" styleClass="home">Help</h:outputLink>
<h:outputLink value="#" styleClass="home">About</h:outputLink>
</li>
但是,内容是动态的,我使用了 Tomahawk 库
<t:htmlTag value="ul" binding="#sessionBean.menu"
styleClass="nav navbar-nav">
</t:htmlTag>
我要创建链接集的方法绑定
public UIComponent getMenu()
if (menu != null)
menu.getChildren().clear();
HtmlOutputLink htmlOutputLink = new HtmlOutputLink();
htmlOutputLink.setValue("#");
//htmlOutputLink.set //how to set the body link
menu.getChildren().add(htmlOutputLink);
但我不知道如何设置链接的正文,设置正文链接的最佳方法是 HTMLOutputLink commonent?
【问题讨论】:
【参考方案1】:尝试添加:
HtmlOutputText yourOuput = new HtmlOutputText ();
yourOuput.setValue("home"):
htmlOutputLink.getChildren().add(yourOuput);
【讨论】:
以上是关于JSF2 - 以编程方式创建 HtmloutputLink的主要内容,如果未能解决你的问题,请参考以下文章
JSF 2.0 在整个会话中从浏览器和以编程方式设置区域设置 [重复]
JSF 2.3 基于表单的登录和 ViewExpiredException
Android Gradle 插件LintOptions 配置 ⑦ ( explainIssues 属性配置 | htmlOutput 属性配置 | htmlReport 属性配置 )