【问题标题】:Change jsf page title dynamically动态更改jsf页面标题
【发布时间】:2023-03-21 02:22:01
【问题描述】:

我的页面上有两个标签 - ui:composition

1) - ui:define name="title" 
2) - ui:define name="content"

在“内容”下,我有一个表单,其中显示了一些页面标题,例如 -

    h:form id="headingForm"
            <h3>#{Some_Heading_Here}</h3>

页面内容会根据某些条件(按钮点击、链接点击等)进行更新,并行我正在用一些不同的文本更新“headingForm”。 因此,我无法在更新“headingForm”内容时更新“title”内容。 这可能是我在做什么吗?如果是,那么最好的方法是什么。

【问题讨论】:

  • 这个问题有些模棱两可。当您说“jsf 页面标题”时,您实际上不是指&lt;head&gt;&lt;title&gt; 元素的值中的“HTML 页面标题”吗?
  • 实际上在我的页面上我有标题组件 - “#{some_title}”,我需要动态更新它。
  • 这是可以接受的骗局吗? stackoverflow.com/questions/10738211/can-i-update-the-title-bar 问题仅假设 PrimeFaces 而您的则不假设,但技术答案完全相同。

标签: jsf facelets


【解决方案1】:

就是这么简单。 就喜欢它:

 <ui:define name="header">
    <title>#{Some_Heading_Here}</title>
</ui:define>

并且您的 template.xhtml 更改 ( ui:insert ) 为类似的东西:

<h:head>
   <ui:insert name="header">
      <ui:include src="/template/commonContent.xhtml"/>
   </ui:insert>
</h:head>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-13
    • 2020-06-30
    • 1970-01-01
    相关资源
    最近更新 更多