例如,以下代码段:
<h:form id="levelone">
<h:inputText id="leveltwo" value="Test" />
</h:form>
Run Code Online (Sandbox Code Playgroud)
生成以下标记:
<form id="levelone" name="levelone" method="post" action="/test/testPage.html"
enctype="application/x-www-form-urlencoded">
<input id="levelone:leveltwo" type="text" name="levelone:leveltwo"
value="Test" />
</form>
Run Code Online (Sandbox Code Playgroud)
是否可以更改自动生成的ID以使用与冒号不同的分隔符?
例如,我想改变
levelone:leveltwo
Run Code Online (Sandbox Code Playgroud)
至
levelone-leveltwo
Run Code Online (Sandbox Code Playgroud)
我们在webapp中使用Mojo JavaScript应用程序框架,它似乎不喜欢id中的冒号.
我正在使用Eclipse与PrimeFaces一起工作:
<ui:composition 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:p="http://primefaces.prime.com.tr/ui"
template="/template/ui.xhtml">
Run Code Online (Sandbox Code Playgroud)
我看到了Bozho的问答.
因此它仅适用于h和f标签而不适用于p(primefaces)标签!它如何自动完成primefaces标签?
是否可以将JSF facelets和ManagedBeans打包到JAR文件中?这样我们就可以在不同的war/ear项目中使用这个代码和UI组合?
我不是在谈论JSF组件!
如果是的话 - 你可以指点我的教程或博客文章
我需要有关Jar结构和Jar中所需的其他文件的详细信息?
谢谢马克斯
我有以下模板(masterLayout.xhtml):
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<f:view contentType="text/html">
<ui:insert name="metadata"/>
<h:head>
<title><ui:insert name="windowTitle"/> | MySite</title>
</h:head>
<h:body>
<div id="container">
<div id="header">
<ui:insert name="header">
<ui:include src="/WEB-INF/templates/header.xhtml"/>
</ui:insert>
</div>
<div id="content">
<ui:insert name="content"/>
</div>
<div id="footer">
<ui:insert name="footer">
<ui:include src="/WEB-INF/templates/footer.xhtml"/>
</ui:insert>
</div>
</div>
</h:body>
</f:view>
</html>
Run Code Online (Sandbox Code Playgroud)
和使用它的页面(search.xhtml):
<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:f="http://java.sun.com/jsf/core">
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/WEB-INF/templates/masterLayout.xhtml">
<ui:define name="metadata">
<f:metadata>
<f:viewParam name="address" value="#{searchBean.address}"/>
<f:event type="preRenderView" listener="#{userSessionBean.preRenderViewCookieLogin(e)}"/>
<f:event type="preRenderView" listener="#{searchBean.preRenderView(e)}"/>
</f:metadata>
</ui:define>
<ui:define name="windowTitle">#{searchBean.address}</ui:define>
<ui:define name="content">
<!-- Content goes here --> …Run Code Online (Sandbox Code Playgroud) 在JSF中,我可以将Faces Servlet映射到各种URL模式.例如*.xhtml.
但我想要的是将Faces Servlet映射到无扩展名.这意味着,如果customers.xhtml我的网页根目录中有一个页面,我想请求使用http://example.com/customers.
我查看了如何在没有文件扩展名的情况下配置JSF url映射的问题?这在某种程度上有效,但它需要我单独映射我拥有的每个文件(如果我错了,请纠正我).
如何将所有.xhtml文件一次映射到Faces Servlet而无需单独映射?
我有一个可能在不同应用程序中使用的Facelet.我不复制它,但重复使用它.我需要传递将视图作为参数进行管理的辅助bean,因为某些逻辑可能会根据使用它的应用程序而有所不同.
我不想使用复合组件,只是包含Facelet并指定哪个bean将管理视图.我怎样才能做到这一点?
让我举个例子:
<ui:composition template="/resources/common/templates/template.xhtml"
xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich" xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<ui:define name="content">
<!-- somehow establish the backing bean that will manage formView.xhtml -->
<!-- f:set assign="ParameterBean" value="#{Bean}" / -->
<ui:include src="formView.xhtml" />
</ui:define>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)
formView.xhtml:
<ui:composition template="/resources/common/templates/template.xhtml"
xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich" xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<ui:define name="content">
<h:outputText value="#{ParameterBean.texto}" />
</ui:define>
</ui:composition>
Run Code Online (Sandbox Code Playgroud) 我想根据bean值设置一个ui:param,我想用c:if是个好主意.所以我在我的页面中输入以下代码:
<ui:composition 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:c="http://java.sun.com/jsp/jstl/core"
xmlns:wai="http://www.id.ethz.ch/wai/jsf"
template="/view/listView.xhtml">
<c:if test="#{subscriptionListController.model.listViewName eq 'mySubscriptions'}">
<ui:param name="title" value="#{msg.subscriptionTitleMySubscriptions}"/>
</c:if>
<c:if test="#{subscriptionListController.model.listViewName eq 'paidSubscriptions'}">
<ui:param name="title" value="#{msg.subscriptionTitlePaidSubscriptions}"/>
</c:if>
<c:if test="#{subscriptionListController.model.listViewName eq 'allSubscriptions'}">
<ui:param name="title" value="#{msg.subscriptionTitleAllSubscriptions}"/>
</c:if>
....
Run Code Online (Sandbox Code Playgroud)
但参数未设置...
如果我打印出来的值,#{subscriptionListController.model.listViewName eq 'mySubscriptions'}我会在相应的情况下得到真值,而在其他两种情况下则为假.
一开始我只有两种可能性并用三元运算符解决了它:
<ui:param name="title" value="#{subscriptionListController.model.listViewName eq 'mySubscriptions' ? msg.subscriptionTitleMySubscriptions : msg.subscriptionTitlePaidSubscriptions}"/>
Run Code Online (Sandbox Code Playgroud)
它起作用了.但现在我有更多的可能性......
我究竟做错了什么?
这里有点奇怪的,我没有看到任何其他的报告,我们最近报告了IE11用户的一些UI错误,经过一些测试我意识到在执行reRender(我使用的是A4J)之后,IE11正在放置HTML错误的地方,例如.
<s:div id="parent" rendered="#{someCondition}">
<div id="brother"></div>
<div id="sister"></div>
</s:div>
Run Code Online (Sandbox Code Playgroud)
在重新渲染之后看起来像这样
<s:div id="parent" rendered="#{someCondition}">
<div id="brother">
<div id="sister"></div>
</div>
</s:div>
Run Code Online (Sandbox Code Playgroud)
这显然是对布局造成严重破坏
我混合JSF/HTML组件相当多,但不认为这应该导致问题?
可能导致这种情况的任何想法?
JSF 1.2 | RichFaces 3.3 | Facelets的
在Facelets中定义自定义组件既简单又快捷,但有一点我无法弄清楚.
Facelets是否可以定义我的自定义组件具有哪些属性?即:我创建了一个以这种方式使用的组件:
<blue:modalWindow id="editFeesWizard" width="500" height="440" title="Wizard">
Run Code Online (Sandbox Code Playgroud)
并在taglib.xml中定义如下:
<!DOCTYPE facelet-taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
"http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
<namespace>...</namespace>
<tag>
<tag-name>modalWindow</tag-name>
<source>components/modalWindow.xhtml</source>
</tag>
</facelet-taglib>
Run Code Online (Sandbox Code Playgroud)
Taglib不包含有关组件属性(id,width,height,title)的任何信息,因此IDE无法检查我的语法,也不能在我输入时建议属性.
我在Facelets文档中找不到关于这个主题的任何内容.以为你可以帮忙.谢谢!
我正在使用Eclipse Luna来实现JSF2.1 Web应用程序,每次我打开项目时,facelet HTML验证器启动,我习惯了eclipse Helios并且它在验证时比luna更快,我不想禁用验证器或者AppXray.我只是不想忍受它
请指教
facelets ×10
jsf ×5
jsf-2 ×5
eclipse ×2
java ×2
primefaces ×2
ajax4jsf ×1
components ×1
eclipse-luna ×1
html ×1
include ×1
jar ×1
java-ee ×1
jsf-1.2 ×1
packaging ×1
parameters ×1
richfaces ×1
taglib ×1