Primefaces <p:outputPanel/> 或 <div/>。我应该使用什么来实现响应式?

Lui*_*que 3 xhtml jsf primefaces responsive-design responsive

使用 Primefaces 设计良好的响应式页面的最佳方法是什么?在 Primefaces 展示中我可以看到两个标签,div 和 outputpanel 之间有什么区别?对于专业页面来说,最好的选择是什么?也许是 panelGrid?我需要专业的观点。

Mel*_*are 5

来自 PrimeFaces 文档:https ://primefaces.github.io/primefaces/8_0/#/core/performance

尝试使用 HTML over JSF 标签

  1. 如果您不需要转义或转换器等其他功能,请特别避免使用 h:outputText。只需在 XHTML 中使用 EL 表达式即可。

  2. 这同样适用于其他一些组件,例如 p:outputPanel。只需使用一个普通的 div 即可。如果您需要使其可更新,您仍然可以使用“passthrough elements”<div jsf:id="...">...</div>jsf:rendered. 例如:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:jsf="http://xmlns.jcp.org/jsf">
    <div class="userDetails" jsf:rendered="#{sessionController.authorized}">
        Name: #{cc.attrs.value.name}
        Details: #{cc.attrs.value.details}
    </div>
</html>
Run Code Online (Sandbox Code Playgroud)

  • 您仍然可以在普通 div 上使用 jsf:rendered 。在我看来,看起来更好一点;) (2认同)