如何使用facelets在JSF(1.2)标签的.xhtml页面中激活eclipse(3.5,WTP)内容?它适用于.jsp文件,但不适用于xhtml.
我谷歌很多,并且在很多地方(包括MyFaces wiki)都说 - "Eclipse无法使用xhtml和facelets"
由于这适用于.jsp文件,我假设可能有一些机制可用于激活该内容辅助.
我开始研究一个已经拥有大量代码库的项目,因此不能选择更改扩展名.额外的插件也是不受欢迎的,但如果没有其他工作可以接受.
(我问的问题是验证某人是否没有找到这个问题的诙谐解决方法 - 否则我知道这是不可能的)
在我的Web应用程序中,我使用Hibernate检索数据并将其显示在RichFaces dataTable中.
在我的MySQL表中有一个类型为"date"的字段.当我将此字段打印到我的Bean中的日志时,它会显示数据库中的正确日期(例如2010-04-21).但在富人:dataTable中,它显示如下:
一零年四月二十零日
所以有一天的差异!
我添加了"f:convertDateTime"转换器并将"type"属性设置为"both"以便显示时间.现在它显示:
4/20/10 10:00:00 PM
我用过的"f:convertDateTime"代码:
<f:convertDateTime locale="locale.US" type="both" dateStyle="short"/>
Run Code Online (Sandbox Code Playgroud)
所以看起来像f:convertDateTime梦想有一段时间,因为MySQL-table字段中没有时间信息!
我究竟做错了什么?要显示正确的日期,我需要做什么?
谢谢汤姆
我开始使用JSF2.0我使用了一个教程作为参考,但我有以下问题:
本教程只使用2个库:jsf-api.jar,jsf-impl.jar(但也有JSTL)从钻嘴鱼科项目.
我试图下载它们但似乎网站无法访问.所以我使用Apache MyFaces,但运行示例我必须添加8个罐子(commons-*,myfaces-*).
如果我使用MyFaces,为什么还需要更多的罐子?我是否应该更喜欢Mojarra?下载页面确实是JSF Mojarra?
谢谢
我在String变量中有一些文本,其中包含回车符和新行\r\n.
text = "Text1\r\nText2\r\nText3";
Run Code Online (Sandbox Code Playgroud)
我用它来呈现它<h:outputtext>.
<h:outputText value="#{bean.text}" />
Run Code Online (Sandbox Code Playgroud)
但它无法识别新的行字符,并在webbrowser中显示如下.
Text1 Text2 Text3
为什么不<h:outputText>打破\n新线?
我该怎么办?我一定要更换\n有<br />?
请考虑以下情形.在会话超时(过期)后,我点击了JSF表单的提交按钮.浏览器显示一些异常消息:
ViewExpiredException:无法恢复视图上下文
我想要做的是,在会话过期后自动重定向到网站的主页.这样做的机制是什么?任何帮助将非常感激.
添加后,我在一个非常简单的JSF 2页面中面临以下异常<h:form>:
java.lang.IllegalStateException: Cannot create a session after the response has been committed
at org.apache.catalina.connector.Request.doGetSession(Request.java:2758)
at org.apache.catalina.connector.Request.getSession(Request.java:2268)
Run Code Online (Sandbox Code Playgroud)
我在Tomcat 7.0.22和JDK 7上使用Mojarra 2.1.3和PrimeFaces3.0M4.
该页面是一个非常基本的数据表:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form>
<p:dataTable var="car" value="#{tableBean.cars}">
......
</p:dataTable>
</h:form>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
页面在浏览器上正确显示,但在控制台上我看到了异常.如果我删除了,Exception确实会消失<h:form>.
这是怎么造成的,我该如何解决?
即使用户知道某些页面的URL,我也想阻止访问某些页面.例如,/localhost:8080/user/home.xhtml(需要先登录)如果没有记录则重定向到/index.xhtml.
在JSF中如何做到这一点?我在Google上读到需要过滤器,但我不知道该怎么做.
我一直遇到标签问题<f:facet>.我正在使用它的其他代码示例,但我不确定它的用途是什么.
我已经编写了一些代码,这些代码在方法上与我见过的其他代码完全相同,除非它包含在<f:facet name=actions>标记中.当我在我的代码周围添加它时,我正在包装它的下拉框在我部署时消失.任何人都可以为此提出建议或让我深入了解如何以及何时使用方面?
这是我的代码,我不打扰添加bean代码,因为它们只是基本的getter和setter,我不认为它们会造成麻烦.
<f:facet name="actions">
<p:selectOneMenu id="SwitchWeekDrpDwnMenu"
value="#{depotWorkloadBean.selectView}"
partialSubmit="true">
<p:ajax update="mainForm"
listener="#{depotWorkloadBean.updateView}" />
<f:selectItem itemLabel="Day view" itemValue="Day"/>
<f:selectItem itemLabel="01/01/2014" itemValue="Week"/>
</p:selectOneMenu>
</f:facet>
Run Code Online (Sandbox Code Playgroud)
如果我删除了facet标签,则显示下拉框,但不能正常运行.
我想UIComponent通过我提供的id从托管bean中找到一些.
我写了以下代码:
private UIComponent getUIComponent(String id) {
return FacesContext.getCurrentInstance().getViewRoot().findComponent(id) ;
}
Run Code Online (Sandbox Code Playgroud)
我已经定义了一个p:inputTextarea:
<p:inputTextarea id="activityDescription" value="#{adminController.activityDTO.activityDescription}" required="true" maxlength="120"
autoResize="true" counter="counter" counterTemplate="{0} characters remaining." cols="80" rows="2" />
Run Code Online (Sandbox Code Playgroud)
现在,如果在getUIComponent("activityDescription")返回方法时调用该方法null,但如果我将其调用,getUIComponent("adminTabView:activityForm:activityDescription")那么我可以获取该org.primefaces.component.inputtextarea.InputTextarea实例.
有没有办法让组件只有id,即"activityDescription"不是绝对id,即"adminTabView:activityForm:activityDescription"?
我正在尝试ajax更新有条件渲染的组件.
<h:form>
...
<h:commandButton value="Login" action="#{login.submit}">
<f:ajax execute="@form" render=":text" />
</h:commandButton>
</h:form>
<h:outputText id="text" value="You're logged in!" rendered="#{not empty user}" />
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用.我可以保证这#{user}实际上是可用的.这是怎么造成的,我该如何解决?
jsf rendered-attribute jsf-2 conditional-rendering ajax-update
jsf ×10
jsf-2 ×7
java ×2
primefaces ×2
ajax-update ×1
eclipse ×1
facelets ×1
facet ×1
forms ×1
hibernate ×1
line-breaks ×1
login ×1
mojarra ×1
myfaces ×1
output ×1
richfaces ×1
session ×1
uicomponents ×1
xhtml ×1