【问题标题】:h:outputText need style for particular texth:outputText 需要特定文本的样式
【发布时间】:2016-04-03 23:34:35
【问题描述】:

我正在使用 Primefaces 5.1。在我的学生中,我需要特定文本中的特定样式。下面的代码我尝试它会显示错误(属性“值”的值不能包含“

<p:outputPanel>
<h:outputText styleClass="noWrap" escape="false" 
value="#{common.ConfirmMessage1} <b style='color:red'>'
#{student.numberOfUserFound}'</b>"/>
</p:outputPanel>

我怀疑单独的文本是解决方案还是其他方式?

【问题讨论】:

  • 只需使用第二个h:outputText 并通过styleClass 属性为其赋予带有粗体红色字体的css 类。 &lt;h:outputText styleClass="noWrap" escape="false" value="#{common.ConfirmMessage1}"/&gt; &lt;h:outputText styleClass="boldRedStyle" value="#{student.numberOfUserFound}"/&gt;
  • @Geinmachi 可以设置相同的输出文本样式吗?

标签: jsf primefaces


【解决方案1】:

只是不要使用&lt;h:outputText&gt;。在这种特定情况下,它没有技术上的必要性。

<p:outputPanel>
    <span class="noWrap">
        #{common.ConfirmMessage1}
        <b style='color:red'>'#{student.numberOfUserFound}'</b>
    </span>
</p:outputPanel>

另见:


话虽如此,我建议从 JSF 退后一步,先开始学习一些 basic HTML。 JSF 将更容易理解。在这个问题的上下文中,JSF 只是一个 HTML 代码生成器。

【讨论】:

  • @Karthik:如果他们有帮助,请接受答案。这就是 stackoverflow 的工作原理。
猜你喜欢
  • 2012-10-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-17
  • 1970-01-01
  • 1970-01-01
  • 2016-09-26
  • 1970-01-01
相关资源
最近更新 更多