jsf-2.2

Using a “Please select” f:selectItem with null/empty value inside a p:selectOneMenu

走远了吗. 提交于 2019-11-26 08:23:15
问题 I\'m populating a <p:selectOneMenu/> from database as follows. <p:selectOneMenu id=\"cmbCountry\" value=\"#{bean.country}\" required=\"true\" converter=\"#{countryConverter}\"> <f:selectItem itemLabel=\"Select\" itemValue=\"#{null}\"/> <f:selectItems var=\"country\" value=\"#{bean.countries}\" itemLabel=\"#{country.countryName}\" itemValue=\"#{country}\"/> <p:ajax update=\"anotherMenu\" listener=/> </p:selectOneMenu> <p:message for=\"cmbCountry\"/> The default selected option, when this page

How to write a file to resource/images folder of the app?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 08:09:52
问题 I would like to upload an image and store it on the server, and later to show it with h:graphicImage? I would like to store it in \"resources/images\" of the app. I am using glassfish 4. Right now, the file goes to \"domain1\\generated\\jsp\\FileUpload\". Thank you My form <h:form id=\"form\" enctype=\"multipart/form-data\"> <h:messages/> <h:panelGrid columns=\"2\"> <h:outputText value=\"File:\"/> <h:inputFile id=\"file\" value=\"#{uploadPage.uploadedFile}\"/> </h:panelGrid> <br/><br/> <h

Which XML namespace to use with JSF 2.2 and up

孤者浪人 提交于 2019-11-26 05:38:14
问题 I have migrated my application from JSF 1.2 to 2.2. It used XML namespaces on java.sun.com domain like xmlns:f=\"http://java.sun.com/jsf/core\" . However, Oracle\'s Java EE 7 tutorial is using XML namespaces on xmlns.jcp.org domain like xmlns:f=\"http://xmlns.jcp.org/jsf/core\" . Which one is recommended and why was this changed? 回答1: Which one is recommended? Go ahead with XML namespaces on xmlns.jcp.org domain. This was newly introduced since Java EE 7 in 2013 (which covers a.o. JSF 2.2,

When using @EJB, does each managed bean get its own @EJB instance?

烈酒焚心 提交于 2019-11-26 04:55:16
问题 I am using JSF 2.2 for a web project and I am implementing the login page now. I have a login.xhtml that serves as the view , and a backing bean called UserLoginView . This bean has an EJB property bean private UserService userService (as shown here). Does this mean that each new UserLoginView gets a new instance of UserService ? Is OK to implement it like this in a production environment? 回答1: Does this mean that each new UserLoginView gets a new instance of UserService? Nope. The given

How to upload file using JSF 2.2 <h:inputFile>? Where is the saved File?

冷暖自知 提交于 2019-11-26 04:52:53
I would like to be able to upload files in my JSF2.2 web application, so I started using the new <h:inputFile> component. My only question is, how can I specify the location, where the files will be saved in the server? I would like to get hold of them as java.io.File instances. This has to be implemented in the backing bean, but I don't clearly understand how. BalusC JSF won't save the file in any predefined location. It will basically just offer you the uploaded file in flavor of a javax.servlet.http.Part instance which is behind the scenes temporarily stored in server's memory and/or

File upload doesn&#39;t work with AJAX in PrimeFaces 4.0/JSF 2.2.x - javax.servlet.ServletException: The request content-type is not a multipart/form-data

社会主义新天地 提交于 2019-11-26 03:53:13
问题 Important : The issue which is discussed in this thread has been fixed as of PrimeFaces 5.1 final (community release) released on Monday, October 6, 2014 (just a few minutes ago from now). I attempted on JSF 2.2.8-02 (or api, impl). As such, if you happened to use that version ( or higher, no need to mention ), you would not even need to read this question anymore. I have a web application running on GlassFish 4.0 Mojarra 2.2.4 PrimeFaces 4.0 final Everything except file upload with AJAX

How to upload file using JSF 2.2 <h:inputFile>? Where is the saved File?

这一生的挚爱 提交于 2019-11-26 01:50:05
问题 I would like to be able to upload files in my JSF2.2 web application, so I started using the new <h:inputFile> component. My only question is, how can I specify the location, where the files will be saved in the server? I would like to get hold of them as java.io.File instances. This has to be implemented in the backing bean, but I don\'t clearly understand how. 回答1: JSF won't save the file in any predefined location. It will basically just offer you the uploaded file in flavor of a javax

How to install and use CDI on Tomcat?

元气小坏坏 提交于 2019-11-25 23:08:22
问题 I\'m creating my first project Java EE 7, but I\'m having trouble. Appreciate any help. Tomcat 7.0.34 JSF 2.2 Primefaces 3.5 javaee-api-7.0.jar When the application start, the Tomcat log shows the following message: \"validateJarFile (C:\\...\\build\\web\\WEB-INF\\lib\\javaee-api-7.0.jar)-jar not loaded. See Servlet 2.3 Spec, section 9.7.2. Offending class: javax/servlet/Servlet .class\" when I click on the button that calls the managed bean, I get the error: Advertência: /index.xhtml @18,66