我需要从动作处理程序中确定表单字段的ID.该字段是包含的facelets组件的一部分,因此表单将有所不同.
included.xhtml
<ui:component>
<h:inputText id="contained_field"/>
<h:commandButton actionListener="#{backingBean.update}" value="Submit"/>
</ui:component>
Run Code Online (Sandbox Code Playgroud)
example_containing.xhtml
<h:form id="containing_form">
<ui:include src="/included.xhtml"/>
</h:form>
Run Code Online (Sandbox Code Playgroud)
如何update在运行时确定方法中表单的ID ?或者更好的是,直接输入字段的ID.
我试图将换行标记
插入到某些文本中并将其显示在网页上.<和>符号正被翻译成<和>,并且标签在网页上显示为文本.
当我从数据库中选择它时,文本看起来像这样(我将它输出到SYSOUT):
version 12.4
service timestamps debug datetime
service timestamps log datetime
service password-encryption
Run Code Online (Sandbox Code Playgroud)
然后我通过这个小过滤器运行它:
public DevConfigs getDevConfig() {
String config = devConfig.getConfig();
Pattern pattern = Pattern.compile(".$", Pattern.MULTILINE | Pattern.DOTALL);
Matcher matcher = pattern.matcher(config);
String newConfig = matcher.replaceAll("<br />");
devConfig.setConfig(newConfig);
return this.devConfig;
}
Run Code Online (Sandbox Code Playgroud)
这是网页(它是使用facelets的Seam应用程序):
<rich:tab label="Config">
hello<br />
there<br />
#{devConfig.config}
</rich:tab>
Run Code Online (Sandbox Code Playgroud)
页面源代码如下:
hello<br />
there<br />
<br />
<br />
version 12.<br />
service timestamps debug datetim<br />
service timestamps log datetim<br />
service …Run Code Online (Sandbox Code Playgroud) 我有一个豆田status.根据status值,应该应用不同的css类来渲染它.
所以,我需要这样的东西(离真实伪代码很远):
if status == "Approved"
cssClass = "green"
if status == "Rejected"
cssClass = "red"
<span class="cssClass">Some info</span>
Run Code Online (Sandbox Code Playgroud)
我试图申请,jstl但我不能使它与facelets和jsf(但我听说这是可能的,也许它的真相).这是代码:
<c:choose>
<c:when test="#{report.approved}">
<c:set var="statusClass" value="approved"/>
</c:when>
<c:when test="#{report.rejected}">
<c:set var="statusClass" value="rejected"/>
</c:when>
<c:when test="#{report.inProgress}">
<c:set var="statusClass" value="progress"/>
</c:when>
<c:when test="#{report.pendingHR}">
<c:set var="statusClass" value="pending"/>
</c:when>
</c:choose>
<span class="status ${statusClass}">#{report.formattedStatus}</span>
Run Code Online (Sandbox Code Playgroud)
如何使用JSF/Facelets?
这个错误信息是什么意思?应该提供什么值来摆脱这个警告?
15:10:58,024 WARNING [component] facelets.RECREATE_VALUE_EXPRESSION_ON_BUIL
D_BEFORE_RESTORE is set to 'true' but facelets.BUILD_BEFORE_RESTORE is set
to 'false' or unset. To use facelets.RECREATE_VALUE_EXPRESSION_ON_BUILD_BEF
ORE_RESTORE you must also set facelets.BUILD_BEFORE_RESTORE to 'true'!
Run Code Online (Sandbox Code Playgroud) 我注意到Netbeans向导创建了Facelets模板客户端页面,可以选择将html或ui:composition作为页面的文档根目录.
我一直都在使用html选项,然后继续使用它以保持一致性.然而我意识到,如果我使用ui:composition,那么我会为我的文档正文保存两级缩进.
保持html的唯一原因是我记得的是我在某个地方读到这种格式在某个IDE中假设有用.但是我从未遇到过它.
有没有理由继续使用html作为文档根目录?
我对于同一主题提出了另一个问题仍犹豫不决,但至少现在我正在阅读正确的文档.
所以,这堂课:
class FacesContextProducer {
@Produces @RequestScoped FacesContext getFacesContext() {
return FacesContext.getCurrentInstance();
}
}
Run Code Online (Sandbox Code Playgroud)
事实上,从焊接文档中,此方法适用于Glassfish: GlassFish使用WELD作为JSR-299的参考实现:Java上下文的Java上下文和依赖注入(CDI).
对于上面的课程,它会在哪里使用?为什么你需要一个单独的类@Produces一个FacesContext?
我们将JSF升级到最新版本2.1.以前我们在JSF2.0.4.我们的xhtml页面具有Targeting IE Using Conditional Comments标记,这些标记未呈现为文本.
但是对于新的JSF2.1.7,这将在IE中呈现为文本.有任何想法如何解决这个问题?
我有一个login.jsp页面:
<form method="post" action="url:8081/login.xhtml">
Username : <input type="text" name="txtUsername"/>
Password : <input type="text" name="txtPassword"/>
<input type="submit" value="submit"/>
</form>
Run Code Online (Sandbox Code Playgroud)
当我提交它时,我如何获得txtUsername和txtPassword参数login.xhtml?
我有以下问题,我们有在远程主机上运行的Web内容管理器(WCM),它负责生成页眉和页脚HTML文件。即header.html,footer.html。HTML文件的语法格式不正确,WCM生成的文件具有
)X XHTML中不允许使用。<br>)标记?在XHTML中无效。因此,WCM生成的HTML页面可能不是有效的XHTML页面。
我们正在JSF中实现一些应用程序,我们需要在其中包含WCM生成的页眉和页脚文件。我们可以将未格式化的HTML文件包含到我们的XHTML文件中吗?
<html>
<head>
..........;
</head>
<body>
<ui:include src="remote_host/header.html" />
<ui:insert name="commonBodyContent" />
<ui:include src="remote_host/footer.html" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 在我的JSF页面中,这有效:
${requestScope.put('test', 'data')}
${requestScope.get('test')}
Run Code Online (Sandbox Code Playgroud)
这会导致异常:
${viewScope.put('test', 'data')}
${viewScope.get('test')}
Run Code Online (Sandbox Code Playgroud)
例外:
java.lang.NullPointerException
javax.el.BeanELResolver.invoke(BeanELResolver.java:159)
javax.el.CompositeELResolver.invoke(CompositeELResolver.java:84)
org.apache.el.parser.AstValue.getValue(AstValue.java:157)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
com.sun.faces.facelets.el.ELText$ELTextVariable.writeText(ELText.java:238)
com.sun.faces.facelets.el.ELText$ELTextComposite.writeText(ELText.java:154)
com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:85)
com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Run Code Online (Sandbox Code Playgroud)
如何requestScope在JSF页面以外使用?我当然可以有一个视图范围的bean,但我认为我可以直接使用范围变量.我有Mojarra 2.2.10的Tomcat 8.0.21.