我正在尝试修改PrimeFaces 菜单(不是 MenuBar),使其水平显示。
我正在尝试应用这样的样式:
<h:form>
<p:menu styleClass="horizontalMenu">
<p:menuitem value="Home" url="./home.xhtml"/>
<p:menuitem value="Contact Us" url="./contactUs.xhtml"/>
<p:menuitem value="Shop" url="./shop.xhtml"/>
</p:menu>
</h:form>
Run Code Online (Sandbox Code Playgroud)
在单独的 CSS 文件中,我有以下内容:
.horizontalMenu li {
display:inline;
float:none;
}
Run Code Online (Sandbox Code Playgroud)
但是,我的样式总是被 PrimeFaces 样式覆盖(例如 .ui-menuitem)。
我希望有一个非全局的解决方案,因为我可能也需要垂直菜单,所以这排除了编辑主题的 CSS 文件。
我正在尝试将简单的 JSF2.2 原型从Mojarra 2.2.5(...工作正常...)迁移到MyFaces 2.2.3,但出现NullPointerException。我通常使用 Mojarra 做的是以编程方式
在容器中
包含(注入)JSF 页面。
示例包含页面(inclusion.xhtml)是:
<h:panelGroup id="container">
</h:panelGroup>
<h:form>
<h:commandButton value="Include page" action="#{inclusion.include('included.xhtml')}" />
</h:form>
Run Code Online (Sandbox Code Playgroud)
包含的页面(included.xhtml)包含类似以下内容:
<h:outputText value="INCLUDED TEXT ..." />
Run Code Online (Sandbox Code Playgroud)
这是托管 bean:
@ManagedBean(name="inclusion")
@RequestScoped
public final class Inclusion {
public void include(String contentUrl) throws IOException{
FacesContext fc = FacesContext.getCurrentInstance();
FaceletContext f2ctx = (FaceletContext) fc.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
UIComponent uic = fc.getViewRoot().findComponent("container");
if (uic != null && f2ctx != null) {
f2ctx.includeFacelet(uic, contentUrl);
}
} …Run Code Online (Sandbox Code Playgroud) 我用styesheets构建JSF页面.当我在Eclipse中使用预览功能时,它似乎有效,但是当我在IE8上测试它们时,它们似乎没有任何效果.
我使用复合视图来指定页面的一般布局,如下所示.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<link rel="stylesheet" type="text/css" href="/css/masterTemplateCSS/masterTemplateCSS.css" />
<title><ui:insert name="title"></ui:insert></title>
</head>
<body>
<div class="left_Sidebar">
<ui:insert name="leftSidebar">
</ui:insert>
</div>
<div class="bulk_text">
<ui:insert name="content">
</ui:insert>
</div>
<div class="foot">
<ui:insert name="footer">
</ui:insert>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
然后我尝试测试它们.
<ui:composition template="/templates/masterTemplate.xhtml">
<ui:define name="title">Create Screen</ui:define>
<ui:define name="leftSidebar">
Left sidebar
</ui:define>
<ui:define name="content">
Run Code Online (Sandbox Code Playgroud)
模板有效,我相信css路径是正确的.我还用验证器测试了css文件,他们都检查了.但它仍然似乎在实际的浏览器中工作:S
我正在尝试制作一个简单的PrimeFaces示例,例如他们网站上的教程.我基本上和这个用户有完全相同的问题,但我没有像他那样的空jar文件.h:标签渲染正常,但p:标签在HTML中显示为p:标签.PrimeFaces 3.1.1和3.2也存在同样的问题.这是我的web.xml文件.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>jsf</display-name>
<welcome-file-list>
<welcome-file>Login.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<description></description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description></description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description></description>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener- class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)
我的XHTML文件看起来像这样.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head> …Run Code Online (Sandbox Code Playgroud) 当我在Netbeans中编译JSF页面时,我对JSF页面和faces-config.xml文件中的注释会发生什么感兴趣?它们是保留还是由编译器删除.如果它们被保存,我可以以某种方式删除它们吗?我知道编译器会删除java bean代码中的注释,但我不确定JSF页面.
我一直致力于一个项目,并试图了解这些组件的工作原理.我对每个人扮演的角色感到困惑.我目前的任务是在Tomcat 5.5中使用一个利用JSF,MyFaces,Trinidad和Facelets的项目,并让它在Tomcat 6.0中运行.当我在新容器中运行它时,我的行为非常奇怪.所以我想弄清楚我是否需要更新这些库中的任何一个.但我似乎无法弄清楚这些是如何一起工作的.所以这里有一些问题:
鉴于此信息,Tomcat版本是否对这些框架有直接影响?
是否可以完全显示以前创建的Facelets页面<p:dialog>?
我有2个Facelets文件(index.xhtml和report.xhtml).我使用RichFaces <ui:include src="report.xhtml"/>将报告加载到索引中.工作良好.但是,当我尝试仅显示某些条件的报告时,我失败了!什么不起作用是这样的:
<ui:include src="report.xhtml" rendered="#{indexService.contentName == 'report'}"/>.
ui:include的呈现属性似乎不起作用.
如何在某些条件下将report.xhtml加载到index.xhtml中?我的代码中的错误在哪里?
编辑:
其中一半现在有效.更改Facelet文件适用于条件.但加载的Facelet的功能无法正常工作.这是为什么?代码中的问题在哪里?
基于我现在的建议:
<h:form>
<h:panelGrid>
<a4j:commandLink value="Home" render="contentpanel" action="#{indexService.setContentName('home')}"/>
<a4j:commandLink value="Report" render="contentpanel" action="#{indexService.setContentName('report')}"/>
</h:panelGrid>
</h:form>
<a4j:outputPanel id="contentpanel">
<ui:fragment rendered="#{indexService.contentName eq 'report'}">
<ui:include src="report.xhtml" />
</ui:fragment>
</a4j:outputPanel>
Run Code Online (Sandbox Code Playgroud)
编辑2:
这是我的报告Facelet.如果我在没有任何条件的情况下使用报告Facelet的功能完美,但如果我使用我在编辑1中发布的条件加载它,那么按钮<rich:panelMenuItem .../>不再起作用并且<h:outputText escape="false" value="#{reportService.content}"/>不加载内容.知道为什么吗?
编辑3:
改变了<rich:panel header="Report">...</rich:panel>,但行为仍未改变.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<ui:composition>
<h:outputStylesheet>
.placesmenu {
width: 200px;
vertical-align: top;
}
.contentplace {
vertical-align: …Run Code Online (Sandbox Code Playgroud) 在开发JSP页面时,我们可以在服务器端运行Java代码,而JSP页面在客户端运行...如何在Java代码(在服务器端)和JSP页面(在客户端)之间创建请求和响应周期这个动态网页的JSP和JSF技术有什么区别?哪一个更好的JSF或JSP?
<f:view>标签是否应该在标签外面(周围)<rich:page>?还是里面呢?
请注意,我确实想要一个<f:view>标签,因为我想设置locale.