【问题标题】:Applying <p:commandButton> style to <p:commandLink> because I basically need <p:commandButton target="_blank">将 <p:commandButton> 样式应用于 <p:commandLink> 因为我基本上需要 <p:commandButton target="_blank">
【发布时间】:2013-10-10 21:52:33
【问题描述】:

有谁知道如何将相同样式从命令按钮放到所有命令链接?

我希望所有链接都像这样(覆盖链接样式并使用按钮样式):

普通按钮:

悬停按钮:

按下的按钮:

我目前的 primefaces 主题是 start

【问题讨论】:

  • &lt;h:link&gt;&lt;a&gt; 上应用&lt;p:commandButton&gt; 样式是可以理解和合理的,但是在&lt;p:commandLink&gt; 上呢?为什么不直接将其设为&lt;p:commandButton&gt;
  • @BalusC 因为我需要在浏览器中打开一个新选项卡来显示 pdf 文件,而 没有目标属性
  • 不起作用,但 起作用。另一种方法是将 样式放到所有 组件中。你能帮我做一些这些事情吗,拜托
  • 不能使用&lt;h:form target="_blank"&gt;&lt;p:commandButton ajax="false" onclick="form.target='_blank'"&gt;
  • 太好了,第二个被选中了。感谢@BalusC,您可以将此评论作为答案以立即选择它

标签: jsf primefaces commandlink commandbutton


【解决方案1】:

根据 cmets,只需坚持&lt;p:commandButton&gt; 并使用替代解决方案即可解决需要在新窗口中打开 PDF 文件下载的初始功能需求,而无需显式设置 &lt;h:form target&gt;(这将影响所有表单的命令按钮/链接)。

<p:commandButton ... ajax="false" onclick="form.target='_blank'">

这最终会减少 CSS 的痛苦。

【讨论】:

  • 感谢@BalusC。一如既往,你是最伟大的人
  • @BalusC,我的问题的完美解决方案,我不知道在余下的 JSF 生活中我还需要说多少次“你太棒了”。
【解决方案2】:

您可以将命令按钮中使用的样式表用于命令链接。

  <p:commandLink style="padding: .3em 1em;" styleClass="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-button-text ui-c" ajax="false" value="Download as Excel" download="#{salaryCycleController.current}.xls" onclick="return ExcellentExport.excel(this, 'tbl', 'Sheet1');" ></p:commandLink>

我不得不使用 p:commandLink 因为 p:commandButton 不支持下载属性。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-15
    • 2013-02-02
    • 1970-01-01
    • 2014-06-22
    • 2013-01-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多