我做了一些阅读和演奏,我还有一些问题,我希望有人可以回答:
那么,我可以在一个JSF页面中使用两个或更多支持bean吗?
<h:intputText value="#{myFirstBean.firstProperty}" />
<h:intputText value="#{mySecondBean.secondProperty}" />
Run Code Online (Sandbox Code Playgroud)
如果可以的话,我为什么不这样做?(我想我不应该,因为没有人这样做)
如果我不能,为什么?
此外,我在某处读到类似"在页面上加载框架将实例化支持bean,并填充它,如果它是一个回发".他们说,在支持bean,但我不明白的框架如何知道哪些支持bean实例.
我想动态选择一个facelet来渲染我的数据列表中的一些项目.第一次尝试将是:
<ui:repeat value="#{panels}" var="panel">
<ui:include src="#{panel.facelet}">
</ui:repeat>
但是因为ui的src所以它不会起作用:include太早评估了.facelet信息是真正动态的,所以我不能使用c:forEach(不是真的建议与facelets混合使用).我想这一切都归结为找到一个基于ui的组件:包括替代品.
是否有这样的事情或者我需要自己编写?
是否可以将facelets用作Spring MVC的视图技术?官方文档中没有提及它,但我听说Facelets非常方便易用,我想尝试一下,我只是不知道如何...
是否有Eclipse的代码生成器可以创建基于JPA POJO字段的facelets表单?
我只是想找一些可以检查我的JPA实体并根据它打出一个表格的东西.不需要漂亮.我正在使用常规的Eclipse Helios Java EE发行版.如果我必须安装插件或其他东西,只要它是免费的就可以了.
作为替代方案,如果你知道任何其他可以做到这一点的工具也会很好,只要它不需要安装另一个IDE.我在这里寻找快速和肮脏的东西.
TIA.
我尝试在Facelets页面中激活EL提议,但是当我按下Ctrl + Space时,它不起作用.我设法激活JSF标签提议感谢其他问题,但EL提案不起作用.
如何在Eclipse中激活此功能?这是一个已知的问题吗?
例如:
<h:inputHidden id="id" value="#{Ctrl+Space not working!}"/>
Run Code Online (Sandbox Code Playgroud) 我正在学习使用JSF 2.0的复合组件,我希望我的组件能够从支持bean中触发方法,所以我创建了一个简单的例子,但是出了点问题.
这是我创建的组件:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="attribute1"/>
<composite:attribute name="attribute2"/>
<composite:attribute name="actionBtnText"/>
<composite:attribute name="actionMethod" method-signature="java.lang.String action()"/>
</composite:interface>
<composite:implementation>
<h:form>
<h:inputText value="#{cc.attrs.attribute1}"/>
<br/>
<h:inputText value="#{cc.attrs.attribute2}"/>
<br/>
<h:commandButton action="#{cc.attrs.actionMethod}" value="#{cc.attrs.actionBtnText}"/>
</h:form>
</composite:implementation>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我在JSF页面中使用它的方式
<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:f="http://java.sun.com/jsf/core"
xmlns:custom="http://java.sun.com/jsf/composite/custom">
...
<h:body>
<custom:demoCustomComponent attribute1="#{demoBB.value1 }" attribute2="#{demoBB.value2 }" actionBtnText="Button text!" actionBtn="#{demoBB.act}"/>
</h:body>
Run Code Online (Sandbox Code Playgroud)
这是支持组件所在页面的支持bean
@Named("demoBB")
@RequestScoped
public class DemoBB {
private String value1;
private String value2;
public String getValue1() {
return value1;
}
public String act() {
System.out.println("Input 1: " + value1 …Run Code Online (Sandbox Code Playgroud) 我们在oracle Web logic app服务器上运行了一个带有两个集群服务器的实例.
其中一个服务器运行顺利,但另一个服务器在登录页面上发出错误.
我检查了日志但什么都没有,任何想法在哪里看?
登录页面错误:
com.sun.facelets.FaceletException: Error Parsing /content/templates/baseLayout.xhtml: Error Traced[line: 1] Content is not allowed in prolog.
at com.sun.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:234)
at com.sun.facelets.compiler.Compiler.compile(Compiler.java:105)
at com.sun.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:197)
at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:144)
at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:293)
at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:274)
at com.sun.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:145)
at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:113)
at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:248)
at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:295)
at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:274)
at com.sun.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:145)
at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:113)
at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
at com.sun.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:96)
at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:525)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:567)
at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:101)
at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
at org.springframework.faces.webflow.JsfView.render(JsfView.java:94)
at org.springframework.webflow.action.ViewFactoryActionAdapter.doExecute(ViewFactoryActionAdapter.java:40)
at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188)
at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51)
at org.springframework.webflow.engine.EndState.doEnter(EndState.java:101)
at org.springframework.webflow.engine.State.enter(State.java:195)
at org.springframework.webflow.engine.Flow.start(Flow.java:536)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:350) …Run Code Online (Sandbox Code Playgroud) 我正在创建一个JSF2 Facelets复合组件.如果定义了特定的facet,我希望HTML的呈现方式不同.有没有办法检查是否<f:facet name="..." />已为复合组件定义了?
我在<ui:insert name ="content"/>中有一个表单当我使用ap:commandButton保存数据时,我可以更新<ui:insert name ="content"/>中的表单和内容.但我无法弄清楚如何更新<ui:include src ="/ sections/menus/topMenu.xhtml"/>中的组件
在topmenu中我有一个面板的子视图,其中的链接根据一个人是否登录而呈现.当他们登录时,我会显示他们的用户名.如果我更新模板内容部分中的用户名,我想更新ui,以便菜单中的名称也更新而不刷新页面.但这也是我可以使用的后备.更新后刷新页面.但不愿意.如果你愿意的话,我会发布更多的代码,但试图将其保持在最低限度.
<h:body>
<div id="wrap">
<div title="Container">
<ui:include src="/sections/base/header.xhtml"/>
</div><!-- End of Banner -->
<div id="baseTemplateTopMenu" title="Menu">
<ui:include src="/sections/menus/topMenu.xhtml"/>
</div><!-- End of Menu -->
<div id="sbt_contentbody">
<div title="Left Column">
<ui:include src="/sections/base/leftsidebar.xhtml"/>
</div> <!-- End of Left Column -->
<div title="Content Column">
<ui:insert name="content" />
</div><!-- End of Centre Column -->
<div title="Right Column">
<ui:include src="/sections/base/rightsidebar.xhtml"/>
</div><!-- End of Right Column -->
</div>
<div id="footer" title="Footer" class ="container">
<ui:include src="/sections/base/footer.xhtml"/>
</div><!-- End of Footer …Run Code Online (Sandbox Code Playgroud) 我正在阅读http://docs.oracle.com/javaee/7/tutorial/doc/jsf-facelets005.htm#GIQZR上的Java EE 7教程
在我的IDE中的8.5复合组件一章中键入示例代码并在GlassFish4.0上运行示例后,我收到错误
java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.putIfAbsent(ConcurrentHashMap.java:1078)
at com.sun.faces.util.Cache.get(Cache.java:116)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.getComponentMetadata(FaceletViewHandlingStrategy.java:237)
at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:951)
at javax.faces.application.ApplicationWrapper.createComponent(ApplicationWrapper.java:648)
Run Code Online (Sandbox Code Playgroud)
然后我查看本教程的旧版本,我发现了一个区别.
在Java EE 7版本中,email.xhtml代码如下:
<!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:composite="http://xmlns.jcp.org/jsf/composite"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>This content will not be displayed</title>
</h:head>
<h:body>
<composite:interface>
<composite:attribute name="value" required="false"/>
</composite:interface>
<composite:implementation>
<h:outputLabel value="Email id: "></h:outputLabel>
<h:inputText value="#{cc.attrs.value}"></h:inputText>
</composite:implementation>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
但是在Java EE 6版本中
<!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:composite="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>This content will not be displayed</title>
</h:head> …Run Code Online (Sandbox Code Playgroud)