简体   繁体   English

JSF2环境设置

[英]JSF2 environment set up

I am a new web developer who is struggling to even set up local development environment with Eclipse. 我是一名新的Web开发人员,他甚至努力使用Eclipse建立本地开发环境。 My goal is to eventually put my idea into a cool website that could be hosted on 64MB private JVM Tomcat 6 server ( here ). 我的目标是最终将我的想法放到一个不错的网站上,该网站可以托管在64MB私有JVM Tomcat 6服务器( 此处 )上。

I tried everything I could last 4 days reading bunch of tutorial sites and came up with an Eclipse project which could be downloaded. 我花了4天的时间阅读所有教程站点,并尝试了一个可以下载的Eclipse项目。 download . 下载

I am overwhelmed with integrating so many frameworks (I wasn't an open source guy before), I feel that I'm stuck. 集成这么多框架使我不知所措(以前我不是开源人员),我觉得自己很固执。 Following are some questions I have. 以下是我的一些问题。

  1. How come when I run above project on Tomcat 6 server on local machine, I have to access it with "http://localhost/richfaces-tomcat6/" I want to be able to access it with "http://localhost/Namo/". 当我在本地计算机上的Tomcat 6服务器上运行以上项目时,为什么要使用“ http:// localhost / richfaces-tomcat6 /”访问它,我希望能够使用“ http:// localhost / Namo”访问它/”。 Because "Namo" is going to be my website name. 因为“ Namo”将成为我的网站名称。
  2. How come "http://localhost/richfaces-tomcat6/index.xhtml" is not showing the inputText at all? 为什么“ http://localhost/richfaces-tomcat6/index.xhtml”根本不显示inputText?
  3. How come I cannot use "@Named" annotation for the managed beans? 为什么不能为托管bean使用“ @Named”注释? Instead I have to use "@ManagedBean". 相反,我必须使用“ @ManagedBean”。 I read some where that @ManagedBean is really for the legacy system. 我读了一些@ManagedBean真正用于旧系统的地方。 Does this matter? 这有关系吗?
  4. I am trying to code in JSF 2 with a bit of Ajax features on the site. 我正在尝试使用该站点上的Ajax功能在JSF 2中进行编码。 I read some where Richfaces is useful. 我读了一些Richfaces有用的地方。 Am I even on the right track with setting these up? 设置这些设置是否在正确的轨道上?

I know I am asking a lot of questions. 我知道我在问很多问题。 I am so ready to have something set up locally and hit the books for JSF but I can't even get started on it which is very frustrating. 我已经准备好在本地设置一些东西,并为JSF买书,但我什至无法开始,这令人非常沮丧。 I would really appreciate it if somebody could help me or guide me to right direction. 如果有人可以帮助我或指导我朝正确的方向前进,我将不胜感激。

How come when I run above project on Tomcat 6 server on local machine, I have to access it with "http://localhost/richfaces-tomcat6/" I want to be able to access it with "http://localhost/Namo/". 当我在本地计算机上的Tomcat 6服务器上运行以上项目时,为什么要使用“ http:// localhost / richfaces-tomcat6 /”访问它,我希望能够使用“ http:// localhost / Namo”访问它/”。 Because "Namo" is going to be my website name. 因为“ Namo”将成为我的网站名称。

The context path defaults to the Eclipse project name. 上下文路径默认为Eclipse项目名称。 You should have edited the context path in one of the last steps of the Eclipse project creation wizard. 您应该已经在Eclipse项目创建向导的最后一个步骤中编辑了上下文路径。 You can always edit it afterwards in the Web Project Settings section of the project's properties (rightclick project and choose Properties ). 之后,您始终可以在项目属性的“ Web项目设置”部分中对其进行编辑(右键单击项目并选择“ 属性” )。


How come "http://localhost/richfaces-tomcat6/index.xhtml" is not showing the inputText at all? 为什么“ http://localhost/richfaces-tomcat6/index.xhtml”根本不显示inputText?

Apparenty the request URL did not match the URL pattern of the FacesServlet as definied in web.xml . 显然,请求URL与web.xml中定义的FacesServlet的URL模式不匹配。 The given URL expects it to be mapped on an <url-pattern> of *.xhtml . 给定的URL希望将其映射到*.xhtml<url-pattern>上。 Eclipse defaults to /faces/* and/or *.jsf and would require you to open the page by either http://localhost/richfaces-tomcat6/faces/index.xhtml or http://localhost/richfaces-tomcat6/index.jsf . Eclipse的默认值为/faces/*和/或*.jsf ,要求您通过http://localhost/richfaces-tomcat6/faces/index.xhtmlhttp:// localhost / richfaces-tomcat6 / index打开页面.jsf But mapping the FacesServlet on *.xhtml is much better. 但是将FacesServlet映射到*.xhtml会更好。


How come I cannot use "@Named" annotation for the managed beans? 为什么不能为托管bean使用“ @Named”注释? Instead I have to use "@ManagedBean". 相反,我必须使用“ @ManagedBean”。 I read some where that @ManagedBean is really for the legacy system. 我读了一些@ManagedBean真正用于旧系统的地方。 Does this matter? 这有关系吗?

The @Named annotation is part of CDI which is part of Java EE 6. Tomcat is however a simple JSP/Servlet container and not a full fledged Java EE container. @Named批注是CDI的一部分,而CDI是Java EE 6的一部分。但是,Tomcat是简单的JSP / Servlet容器,而不是完整的Java EE容器。 You'd either need to install CDI yourself if you want to use it on Tomcat, or to replace Tomcat by a fuller fledged Java EE container, such as Glassfish 3 or JBoss AS. 如果要在Tomcat上使用CDI,则需要自己安装CDI,或者用功能更完善的Java EE容器(例如Glassfish 3或JBoss AS)替换Tomcat。 See also the Weld documentation (Weld is the codename of the CDI reference implementation). 另请参阅焊接文档 (焊接是CDI参考实现的代号)。 Note that you don't necessarily need CDI to get JSF to run. 请注意,运行JSF不一定需要 CDI。 Using @ManagedBean ought to be sufficient for a simple web application. 对于一个简单的Web应用程序,使用@ManagedBean应该足够了。


I am trying to code in JSF 2 with a bit of Ajax features on the site. 我正在尝试使用该站点上的Ajax功能在JSF 2中进行编码。 I read some where Richfaces is useful. 我读了一些Richfaces有用的地方。 Am I even on the right track with setting these up? 设置这些设置是否在正确的轨道上?

JSF2 already supports Ajax out the box with the <f:ajax> tag. JSF2已经通过<f:ajax>标记支持Ajax。 RichFaces is just a component library which offers more enhanced components and skinnability support on top of the standard component set . RichFaces只是一个组件库,它在标准组件集的基础上提供了更多增强的组件和可换肤性支持 See also Communication in JSF 2.0 . 另请参见JSF 2.0中的Communication

1, 2 JSF 2.0 tutorial with eclipse tomcat 1,2个 带有Eclipse Tomcat的JSF 2.0教程

3 @ManagedBean makes sense for applications that use JSF but do not use JSR 299 3 @ManagedBean对于使用JSF但不使用JSR 299的应用程序有意义

4 yes you can do some cool stuff using RF, also jsf 2.0 has support of <f:ajax> so without RF using default implementation you could also do the AJAX stuff 4是的,您可以使用RF做一些很酷的事情,而且jsf 2.0也支持<f:ajax>因此如果没有使用默认实现的RF,您也可以做AJAX事情

您有严格的内存限制,因此,我建议您为页面使用轻量级的模板引擎(例如VelocityFreemarker)以及诸如Struts / Struts 2Spring MVC的MVC框架

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM