managed-bean

Which scope to use for a series of pages, each dependent on the previous page?

南笙酒味 提交于 2020-01-03 03:06:06
问题 Currently I have four pages that are each backed by their own RequestScoped managed bean. An example of this would be the following... backing search.xhtml @RequestScoped SearchBean backing result.xhtml @RequestScoped ResultBean backing detail.xhtml @RequestScoped DetailBean backing action.xhtml @RequestScoped ActionBean In each page (except for the search page), I inject the bean from the previous page to access the input parameters. For instance... @RequestScoped public class Result {

Integrating JSF managed bean annotations with Spring Boot

走远了吗. 提交于 2020-01-03 03:01:11
问题 I use Spring boot with JSF 2.2. My problem is that I can create @ManagedBean from javax.annotation.ManagedBean and it is working in my index.xhtml when I run the app, but when I want to use javax.faces.bean.ManagedBean is not displaying the value. What's the difference between those two? Why I can't use the javax.faces.bean.ManagedBean ? ( I don't have web.xml file, all is configured in classes) 回答1: The javax.annotation.* annotations are meant to be a move from the classic JSF annotations to

Where should I open / close JMS connections in a JSF ManagedBean?

百般思念 提交于 2020-01-01 12:01:09
问题 In a simple demo web app using JSF 2 and Ajax, there is a method in the ManagedBean which receives messages from a JMS queue: @ManagedBean public class Bean { @Resource(mappedName = "jms/HabariConnectionFactory") private ConnectionFactory connectionFactory; @Resource(mappedName = "jms/TOOL.DEFAULT") private Queue queue; public String getMessage() { String result = "no message"; try { Connection connection = connectionFactory.createConnection(); connection.start(); Session session = connection

Migrate JSF managed beans to CDI managed beans

廉价感情. 提交于 2020-01-01 05:00:07
问题 I'm planning to convert a web app from using JSF managed bean to using CDI managed beans. I know I'll need to do below: Add a empty beans.xml file in WEB-INF. Replace all JSF @ManagedBean to CDI @Named annotations. Replace all JSF scope annotations with CDI or OmniFaces scope annotations. Replace all JSF @ManagedProperty with CDI @Inject annotations. Is that all that needs to be done? Are there any gotchas that I need to be aware of? 回答1: Basically, that's indeed all you need to do provided

How to redirect after login?

筅森魡賤 提交于 2019-12-31 05:04:06
问题 I've username and password bound to the backing managed bean. In the backing bean, when I check the username and password with DB, I want to redirect the page from login.xhtml to home.xhtml . How can I do that? 回答1: Just return the view ID appended with faces-redirect=true parameter. E.g. public String login() { User found = userService.find(username, password); if (found != null) { this.user = found; return "home?faces-redirect=true"; // Will redirect to home.xhtml. } else {

WELD-001408: Unsatisfied dependencies for type Customer with qualifiers @Default

那年仲夏 提交于 2019-12-30 01:34:33
问题 I'm a Java EE-newbie. I want to test JSF and therefore made a simple program but can not deploy it. I get the following error message: cannot Deploy onlineshop-war deploy is failing=Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Customer with qualifiers @Default at injection point [BackedAnnotatedField] @Inject private de.java2enterprise.onlineshop.RegisterController.customer at de.java2enterprise

JSF 2 localization (managed bean)

我是研究僧i 提交于 2019-12-29 15:02:11
问题 I have a properties file for localization: foo=Bar title=Widget Application This is tied in as a resource-bundle in the faces-config: <resource-bundle> <base-name>com.example.messages.messages</base-name> <var>msgs</var> </resource-bundle> I can access this just fine in the facelets view using EL: <title>#{msgs.title}</title> However, if there are things like SQLExceptions, I need to be able to write messages from the managed bean. This is all working also: FacesMessage message = new

JSF 2 localization (managed bean)

天大地大妈咪最大 提交于 2019-12-29 15:02:08
问题 I have a properties file for localization: foo=Bar title=Widget Application This is tied in as a resource-bundle in the faces-config: <resource-bundle> <base-name>com.example.messages.messages</base-name> <var>msgs</var> </resource-bundle> I can access this just fine in the facelets view using EL: <title>#{msgs.title}</title> However, if there are things like SQLExceptions, I need to be able to write messages from the managed bean. This is all working also: FacesMessage message = new

Managed bean is not constructed

我怕爱的太早我们不能终老 提交于 2019-12-29 09:27:10
问题 My JSF managed bean is not constructed when I hit the page. This is my facelet: <h:dataTable value="#{productsBean.producten}" var="product"> <h:column>#{product.description}</h:column> <h:column>#{product.price}</h:column> <h:column>#{product.categoryName}</h:column> <h:column> <h:link value="Edit" outcome="/products/edit"> <f:param name="id" value="#{product.product_id}"/> </h:link> </h:column> </h:dataTable> This is my ProductsBean: @ManagedBean(eager=true) @RequestScoped public class

Transaction is required to perform this operation (either use a transaction or extended persistence context)

一曲冷凌霜 提交于 2019-12-29 08:35:09
问题 I'm using Wildfly 10.0.0 Final, Java EE7, Maven and JPA 2.1. When I am querying my database for records it works fine and lists out the employees, but when I am trying to persist a new employee it gives me the following exception: javax.servlet.ServletException: WFLYJPA0060: Transaction is required to perform this operation (either use a transaction or extended persistence context) javax.faces.webapp.FacesServlet.service(FacesServlet.java:671) io.undertow.servlet.handlers.ServletHandler