jsf-2

How to access component value programmatically

拜拜、爱过 提交于 2021-02-19 07:52:29
问题 Lets assume I want to access the value of a sibling component in an ActionListener. The following fragment is not working as expected, resulting in a ClassCastException: java.util.HashSet cannot be cast to java.lang.String public void processAction(final ActionEvent event) { FacesContext ctx = FacesContext.getCurrentInstance(); UIComponent sibling = event.getComponent().findComponent("inputText"); String value = (String) sibling.getValue(); ... } If I change the essential part to the

isValidationFailed default value

北战南征 提交于 2021-02-19 04:31:32
问题 What would the method facesContext.isValidationFailed() return after the Render Response Phase when the validation fails? It returns false for me in this case. 回答1: It will only return true when FacesContext#validationFailed() has been called by the JSF validation internals or by your own code as follows: FacesContext.getCurrentInstance().validationFailed(); As far JSF internal code is concerned, only UIInput#processValidators() and UIViewParameter#processValidators() will implicitly call

c:forEach not working in tomcat 7

时光怂恿深爱的人放手 提交于 2021-02-17 05:55:08
问题 I created simple page using c:forEach tag. Its working in tomcat 6. But not working tomcat 7 . Developed simple web application using JSF 2.0. I run my code in tomcat 6. its working. I deployed in tomcat 7. Its not working. c:forEach tag result not appearing. welcomeJSF.jsp <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%> <%@taglib uri="http://java.sun.com/jsp/jstl/core"

widgetVar cannot be used in p:fileUpload

守給你的承諾、 提交于 2021-02-16 18:51:29
问题 I want to remove the error message when choosing a wrong type of file. I followed the link http://forum.primefaces.org/viewtopic.php?f=3&t=23853 . <p:fileUpload fileUploadListener="#{userProfileUpdateController.upload}" widgetVar="fileuplaodWgt" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" description="Select Images" update="userPhoto" mode="advanced"/> and I import <h:outputScript name="library.js" library="script"></h:outputScript> In library.js $(document).ready(function(){ alert(fileuplaodWgt);

Adding action methods to a composite component

无人久伴 提交于 2021-02-16 05:11:58
问题 I am learning about composite components with JSF 2.0 and i want my component to be able to trigger methods from backing beans, so i created a simple example, but something is wrong. This is the component i created: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:composite="http://java.sun.com/jsf/composite"> <composite:interface> <composite:attribute name="attribute1"/> <composite:attribute name="attribute2"/> <composite:attribute name="actionBtnText"/

Adding action methods to a composite component

让人想犯罪 __ 提交于 2021-02-16 05:10:13
问题 I am learning about composite components with JSF 2.0 and i want my component to be able to trigger methods from backing beans, so i created a simple example, but something is wrong. This is the component i created: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:composite="http://java.sun.com/jsf/composite"> <composite:interface> <composite:attribute name="attribute1"/> <composite:attribute name="attribute2"/> <composite:attribute name="actionBtnText"/

How to change locale in JSF 2.0?

半世苍凉 提交于 2021-02-15 11:46:08
问题 In my app, user should be able to switch the locale (the language used to render text on pages). Tons of tutorials are using FacesContext.getCurrentInstance().getViewRoot().setLocale(). For example: http://www.mkyong.com/jsf2/jsf-2-internationalization-example/. But, that simply doesn't work in JSF 2.0 (it did work in 1.2). The language never switches. No errors or anything. The same code worked fine in JSF 1.2. What is the correct and definitive approach? I have cobbled together a solution,

How to change locale in JSF 2.0?

ⅰ亾dé卋堺 提交于 2021-02-15 11:45:25
问题 In my app, user should be able to switch the locale (the language used to render text on pages). Tons of tutorials are using FacesContext.getCurrentInstance().getViewRoot().setLocale(). For example: http://www.mkyong.com/jsf2/jsf-2-internationalization-example/. But, that simply doesn't work in JSF 2.0 (it did work in 1.2). The language never switches. No errors or anything. The same code worked fine in JSF 1.2. What is the correct and definitive approach? I have cobbled together a solution,

@ManagedProperty equivalent in Spring

*爱你&永不变心* 提交于 2021-02-10 18:58:25
问题 I am using Spring for my DI. Is there an equivalent of @ManagedProperty? I want to inject the value from one view scoped bean into another one on the next page. e.g @Component @Scope("view") public class Page1Bean(){ private String value; } @Component @Scope("view") public class Page2Bean(){ @ManagedProperty(value = #{page1Bean}") //doesnt work in Spring private Page1Bean bean; } 回答1: @Resource or @Autowired should work. @Resource is the Java EE implementation, @Autowired is the spring

@ManagedProperty equivalent in Spring

北城余情 提交于 2021-02-10 18:57:07
问题 I am using Spring for my DI. Is there an equivalent of @ManagedProperty? I want to inject the value from one view scoped bean into another one on the next page. e.g @Component @Scope("view") public class Page1Bean(){ private String value; } @Component @Scope("view") public class Page2Bean(){ @ManagedProperty(value = #{page1Bean}") //doesnt work in Spring private Page1Bean bean; } 回答1: @Resource or @Autowired should work. @Resource is the Java EE implementation, @Autowired is the spring