managed-bean

@PostConstruct didn't get called by JSF if ManagedBean is inside jar library

与世无争的帅哥 提交于 2019-12-18 04:16:47
问题 I'm running with the following problem. I have a few Managed Beans that are shared between, at this moment, two JSF applications. As I don't want to copy and paste the code in the two (more in the coming future) I've put this shared managed beans inside a JAR library. I've followed this blog: http://jsflive.wordpress.com/2011/03/24/custom-component-library/ Well, even if I put the faces-config.xml inside JAR/META-INF/ the @ManagedBean and @ViewScoped didn't work. I couldn't realise why, but

Backing bean in composite component is recreated on every request

☆樱花仙子☆ 提交于 2019-12-18 03:45:45
问题 I have two variables "userId" and "name". When I click for example the "SHOW USERID" button it works fine and sets "renderUserId=true" and it shows it with the "render", but then if I click the other "SHOW" button, the Bean is reconstruct and I loose the "renderUserId=true" and it becomes "false" and "renderName=true" so it shows ok, but the USERID is hidden. My question is, how can I avoid loosing the bean values when I render the xhtml? This is a simple simulation of my code. NOTE: if I use

How to bind List<Integer> values to selectManyListbox in JSF

有些话、适合烂在心里 提交于 2019-12-17 20:57:48
问题 The situation : I have a JavaServer Faces page and a session-scoped managed bean that has two ArrayList<Integer> properties: one for holding a list of possible values and another for holding a list of selected values. On the JSF page there is a <h:selectManyListBox> component with these two properties bound. The problem : after submitting the form the selected values will be converted to string (the property of type ArrayList actually holds a couple of strings!); however, when I use a

Using f:selectItems var in passtrough attribute

依然范特西╮ 提交于 2019-12-17 20:47:23
问题 can I pass expressions to JSF 2 passthrough-attributes? the following code is not working. expression #{country.isoCode} is not evaluated. <h:selectOneMenu value="#{bean.selectedCountry}" styleClass="selectlist"> <f:selectItems value="#{bean.countries}" var="country" itemLabel="#{country.countryName}" pt:data-icon="flag flag-#{country.isoCode}"/> </h:selectOneMenu> I am using namespace xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" and bootstrap-select. attribute "data-icon" is used to show

How to configure a start up managed bean?

非 Y 不嫁゛ 提交于 2019-12-17 19:35:17
问题 I want a managed bean to run internally on start up in my JSF web application when the application loads. How can I write this class and configure in Glassfish? 回答1: In JSF with CDI, observe the initialization of the application scope. @Named @ApplicationScoped public class App { public void startup(@Observes @Initialized(ApplicationScoped.class) Object context) { // ... } public void shutdown(@Observes @Destroyed(ApplicationScoped.class) Object context) { // ... } } When having OmniFaces at

Can I use multiple managed bean in the same xhtml page? [closed]

限于喜欢 提交于 2019-12-17 19:17:09
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . when there are data that are repeated in several pages (reference example) Is that I can load into a single managed bean and I use several managed bean in the same page. What is its impact? 回答1: Can I use multiple managed bean in the same xhtml page? Yes, you can, I highly recommend you to try it :

Calling Primefaces dialog box from Managed Bean function

こ雲淡風輕ζ 提交于 2019-12-17 15:38:05
问题 Hi I have a managed bean with some functions , based on some condition in that function I will like to call a dialog box Managed bean function goes as public String editStudent(){ setReadOnly(false); setButton(true, true, true, false, true, true,true); LockItem lItem; if(selectStudent !=null){ lItem = (LockItem) services.getbyId("LockItem", condition); if (lItem == null){ System.out.println("Student Avalibale for process :::"); studentRedirect(); return "studentEdit.jsf?faces-redirect=true";

what to use, managed beans (backing beans) or entity beans?

本小妞迷上赌 提交于 2019-12-17 07:25:32
问题 I see a lot of examples marking beans as entity beans (@Entity) & named beans (CDI), so as to avoid creating 2 classes (managed bean & entity bean) and also to make use of Bean Validation so that validation can be performed on both client & server. So should I be using a single class or not, are there any issues or should I be having my managed beans or service layer create entity beans using the data from managed beans ? 回答1: The @Named or @ManagedBean annotations are typically used to let

JSF managed bean naming conventions

时光怂恿深爱的人放手 提交于 2019-12-17 06:36:02
问题 These days I used to work with JSF, but there's a "convention" I'm in doubt if I should use. While working with managed beans, people used to name it as XxxxxManagedBean where the prefix can be any name related to your business. Have you worked like that? Particularly, I don't like that much despite makes search easy. Are you using another convention? Thanks for answering this simple doubt. 回答1: There is no strict convention specified by JSF itself. I've seen the following conventions:

How and when is a @ViewScoped bean destroyed in JSF?

我怕爱的太早我们不能终老 提交于 2019-12-17 04:59:53
问题 The lifecycle of the @RequestScoped and @SessionScopedBean managed beans are managed by the Servlet container itself since they are basically stored as an attribute of HttpRequest and HttpSession respectively. How do JSF manage the lifecycle of the @ViewScopedBean ? I know it gets created when the view is created and is usable till there is a postback to a different view. But I found out that is not garbage collected immediately after we move from that view. 回答1: It will be destroyed when a