bean 1 « Bean « JSF Q&A

1. closing browser from backing bean

i had i situation in which i need to open a pop up on clicking a link and depending on the action performed in the pop up something like close etc ...

2. JSF: Backing Beans with nested objects?

JSF 1.1, using a backing bean with a nested objects inside I can read all properties of the nested object. For example assuming a backing bean named "foo" with a nested object ...

3. JSF backing bean structure (best practices)

I hope that in this post, I can get people's opinions on best practices for the interface between JSF pages and backing beans. One thing that I never can settle on is ...

4. Faces Backing Bean initializing

I have a backing bean, and I'd like to load up a few lists when the bean is instantiated, so that the list may be used in a dropdown. Is there a ...

5. How get selected items in backing bean for ?

Pals, I got stuck again while my web development, I am providing multiple selection list to user for selecting many option. A Fragment of JSF Page <h:selectManyListbox id="associatedAS" value="#{maintainForm.selectedAS}"> ...

6. Jsf custom managed bean instantination handler

Which JSF 1.2 component is responsible for instantiating managed bean specified in faces-config.xml? I'd like to replace this component with my custom-made version which will perform some additional tasks after bean instance ...

7. accessing jsf bean from blazeds client

  • How can I access a jsf managed bean (say, icefaces) from a blazeds client?
  • Will it be possible to share the same session information also ? (for eg, if I have a ...

8. JSF in jetty-equinox, Cannot find Bean classes in other bundles!

I have problems running JSF in an OSGi environment. I am using jetty web container and equinox to provide the OSGi functionality. The structure of my application is as follows: The first ...

9. when to use Serializable backing bean in JSF?

when to use Serializable backing bean in JSF? is there any factors to go for serialization like View Scope, Session Scope, Application Scope or is anything else which requires bean to be ...

10. Bean value update problem in jsf 1.1

I have One Jsf form that contains 2 Beans. First Bean scope: Session. Second Bean scope: request. When some values are added via First Bean to second Bean, the updated value ...

11. How JSF2.0 binds Managed Beans with xhtml?

i have very basic question about How JSF2.0 binds Managed Beans with xhtml? say i have inputtext with value="#{}" how this MymanagedBean reference is resolved in JSF 2 ? please consider following points ...

12. How can I get the package path of a JSF managed bean?

I'm trying to upload an external image and I need to save it in a folder where I have a managed bean. Any idea how I could do this?

13. JSF backing bean can't access the override method of the nested calss

i'm using jsf1.2 The xhtml as followings:

<h:commandLink label="Open" action="#{surveySubFmTreeViListWeb.dtw.updatePage}">
then the backing bean looks like:
public class SurveySubFmTreeViListWeb 

14. Curious problem with JSF - web bean doesn't get invoked until the second submit click

I'm having a simple form on which I want to check some basic functions - edit, delete, add. The web bean (supplier) has 4-5 attributes - id, name, surname and comment. ...

15. JSF backing bean should be serializable?

I'm getting these messages:

[#|2010-07-30T11:28:32.723+0000|WARNING|glassfish3.0.1|javax.faces|_ThreadID=37;_ThreadName=Thread-1;|Setting non-serializable attribute value into ViewMap: (key: MyBackingBean, value class:|#]
Do these mean that my JSF backing beans should implement Serializable? ...

16. How to get a caller principal in my backing bean?

This is my backing bean (deployed to GlassFish):

@DeclareRoles({ "USER" })
public class MyBean {
  public MyBean() {}
  public final String getId() {
    Principal p = .. // ...

17. How to read a value from a h:inputHidden in the managed bean

I have a JSF page which has a h:inputHidden component and I am setting a hardcoded value. I have set the id, name and value attributes. But when I access the ...

18. How to send a List from JSF to backing Bean

I am using a Datatable in JSF1.2 to populate the data received from Seam component/ using a List. The data is getting fetched when I use the list. But when, ...

19. New value is not getting updated in the jsf backing bean when submit button is clicked

I am creating a user manager page which updates and adds users in the same page. Relevant parts of the view:

<h:outputText value="Existing User: "/>
<h:selectOneMenu value="#{userManagerBean.existingUser}" valueChangeListener="#{userManagerBean.updateDetails}" onchange="submit();">
    <f:selectItems value="#{userManagerBean.existingUserList}"/>

<h:outputText ...

20. Best practice for implementing MVC in JSF2 managed beans

As the complexity of the web projects that I am working on increases, the need to include a MVC structure is becoming more urgent. My model classes are well defined, ...

21. How to set value in bean using use c:set with jsf?

I have another problem to solve. I have a code on my xhtml page:

<t:dataList id="myDataList" value="#{myBean.myList}" var="element" first="0" `rows="10" dir="LTR" frame="hsides" rules="all">`
<c:set target="#{myBean}" property="fid" value="#{element[0]}"/>
The problem is that value of 'fid' ...

22. How to get all the selected values from h:selectManyListbox in the backend bean in case of JSF?

How to get all the selected values from h:selectManyListbox in the backend bean in case of JSF? If someone can help with an example, that would really help.

23. Automatic Bean Creation

Question: will using

FacesContext context = FacesContext.getCurrentInstance();
Bean bean = (Bean) context.getApplication().evaluateExpressionGet(context, "#{bean}", Bean.class);
cause a new Bean to be instantiated each time the code runs through these statements? Or will it simply refer ...

24. JSF2: Exeptions while submiting to Bean

If I press the submit` button error messages are thrown at server log login.xhtml

    <p:panel header="Login">  

        <p:messages id="msgs" showDetail="true"/>


25. Best practice, how to alter css file in JSF (Solved: How to access JSF 2.0 resources from Managed Bean)

I know how to access resources form view, but how can I access JSF resources from Managed Bean for example to edit css file ? Or I shouldn't try to do ...

26. Changing beans initialized before in faces-config.xml

public class MyBean {
    private Integer [] myField;

    public Integer [] getMyField() {
        return myField;

27. IDEA does not resolve the el for jsf beans

I have declared my beans in faces config for instance:

and I have this code in my xhtml file:

28. Are ApplicationBeans Methods buffered?

I have a JSF 2.0 WebApp that has one application bean that runs a method for drawing a number for example. I don't want 2 requests to run at the same ...

29. JSF Managed Beans performance

I have a web page that has many forms. One for logging in, another for creating an article and another for submitting a comment. Now, each of these forms is backed ...

30. Best way to unit test jsf 2.0 Managed Bean

What is the most effective way of unit testing JSF 2.0 managed beans. I have seen JSFUnit from JBoss but it looks like its for testing the components in the facelets ...

31. JSF 2 : How do you partition your JSF Beans?

I've had a confusing time determining how to partition my JSF Beans. What i have in mind currently :

  1. Have a single JSF Bean (ViewScope - to support multitab in the browser) for ...

32. jsf make backing bean method synchronized

i have a method in backing bean that adds a product in to db. it checks if product is duplicate. however, it's a slow process and JSF UI could fire multiple ...

33. Separation of concerns in JSF Beans?

Im currently using JSF2, and i notice the JSF bean could have a lot of responsibility, and if combined will look like lots of codes. These include :

  1. holding the state / ...

34. Help understanding JSF's multiple calls to managed bean

I'm using h:datatable, here's the revelant line of my code:

 <h:dataTable value="#{account.latestIncomes}" var="mov" >
then I have a Request scoped managedBean with the getter for the latest Incomes:
 public List<Movs> ...

35. single converter class multiple beans issue

i have the next declaration in faces-config.xml:


36. JSF managed bean naming conventions

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 ...

37. JSF polling a database from an application bean at timed intervals

Hey all, I'm pretty new to jsf so if this is a poor question then I apologize. I'm currently working on a school project where I need to access a database ...

38. How can I initiate `genericBean` with some managed bean as a default value at the beginning of an application?

If I had a generic bean in a JSF page. Like this:

<h:outputLabel value="#{genericBean.content}"/>
and this bean was not a managed bean, i.e. in faces-config there were only 2 managed beans :

39. why NPE in this bean?

I have a session bean:

I inject this into a request bean:

40. JSF 1.2 Managed bean inheritance not working

We are inherting a base bean for all our mangagedbeans. The basebean has some common properties defined in it. But we are not able to retrieve the value set in the Base ...

41. Getting a path to a resource file from managed-bean in JSF

I have this situation: I am trying to remove an old avatar image for a user before putting a new one from the managed bean.

String fileName = "resources/img/useravatars/" + getSessionBean().getSearchAccount().getAvatar();
File f ...

42. JSF 2 - How can I get a message bundle string from inside a managed bean?

I would like to be able to retrieve a string from a message bundle from inside a JSF 2 managed bean. This would be done in situations where the string is ...

43. How Can use one connection in all my beans?

I have created 3 classes: The first for connection(Connectionx),the second I'am using it to fill UI as checkbox,selectonemenu(BeanTools) and the third is for my "operations"(NumberOfIssue). 1)The problem that I want to connect ...

44. How to (or should you) avoid long methods/classes in jsf

I'm mostly working with legacy code in a JSF based project and there are lots of quite long classes and methods in backing beans. This is constantly bugging me but when I ...

45. JSF : Disable drop down does not set value to backing bean

I have a requirment in which I need to disable a drop down on certain event through JavaScript and then submit the form. The problem is that when the drop down ...

46. JSF. Not call beans method

Good day. This problem is not caused by the method of the bean, although beann is created, and other fields after the initialization is visible. A method for obtaining the ...

47. Preserving bean values between views

I'm looking for best practices regarding preserving bean values between views using JSF 2. Consider the following scenario:
* In view A, the view scoped bean ABean is instantiated and retrieves data for ...

48. JSF - Two instanciations of the managed-bean

When I access to my page for the fist time, the managed bean used by the page is instanciate two times (I pass two times in the contructor, with the same ...

49. Seperate Managed bean for a popup dialog

I have three screens(views) associated with separate managed beans for each view. And, I have a common pop-up dialog which can be opened in all the views. Can I define a managedbean separately ...

50. Accessing one managed bean from another

I have a simple authorization page which intends the user to type login and password. Based on the results of user input, I define the next page to display. I have ...

51. Distinction between different types of managed beans

I recently read this article: and it got me thinking about the distinction between different beans in my own application. To quickly summarise the gist:


52. JSF Bean data reset issue

On my xhtml page, I am accessing to a variable as #{managedbean.bean.variable} to draw a chart using fusion chart. I also have filter panel on the page to redraw chart. Components ...

53. How get managed bean name from inside the backing bean?

I'm using JSF 1.1. I have the following in my faces-config.xml file:

I want get the managed bean name beanInstance1 ...

54. How to invoke a method on a managed bean when pressing backbutton or F5?

How can I invoke a method on a managed bean when pressing backbutton or F5?

55. Browser back button doesn't clear old backing bean values

We use JSF2, we have a page with form fields with command button linked to backing bean. When we access the form page, enter the values and submit, the backing bean ...

56. ApplicationScope bean that uses a TimerTask (sheduler), good or bad?

I would like to know if it's ok to use TimerTasks inside application
scoped beans. Example, lets say that I want to create a timer task that sends out
a bunch of email's ...

57. Are both getters and setters mandatory in JSF's managed beans?

I have a JSF component which is initialized from a managed bean's getter getProperty(). Is it mandatory to also have a setter setProperty() in that managed bean?

58. How to reference JSF managed beans which are provided in a JAR file?

I have a WAR file with the following structure: enter image description here The JSF managed bean BusinessObjectTypeListController is located in commons-web-1.0.jar in /WEB-INF/lib and referenced in BusinessObjectTypeListView.xhtml. When I run ...

59. Insert new line in a backing bean string value

How to insert a new line between words for a backing bean value and display it on UI using JSF 2.0 framework? If we have address. The street name should be ...

60. browser back + viewscope beans

What the problem is : What happens when clicking on the browser back button --> opens up a page whose viewscoped-managedbean is already destroyed --> submit a request from a commandButton from ...

61. How many views should a backing bean belong to?

I just read through this question: JSF backing bean structure (best practices) and I am trying to understand when I should make a new backing bean in my application. If ...

62. set itemDisabled from backing bean method for each item in list

I have a radiobutton list and would like to disable some items according to the outcome of a backing bean method.

<h:selectOneRadio value="#{managedBean.selectedItem}">
    <f:selectItems value="#{managedBean.selectItems}"

63. t:saveState to save state of Managed Bean with RequestScope - State for Pagination System

I am trying to work with tomahawk-saveState, but it is simply not working. I inserted the following code to my xhtml file (JSF2.0):

 <t:saveState value="#{managedBean1}"/>
Using a managed bean like this one:

65. not changing backing Bean

66. Managed-bean vs. Reference-bean

The "referenced-bean" element represents at design time the promise that a Java object of the specified type will exist at runtime in some scope, under the specified key. This can be used by design time tools to construct user interface dialogs based on the properties of the specified class. The presence or absence of a referenced bean element has no impact ...

67. Value bean or backing bean?

68. Initialize Data Table using Managed Bean

Hi, I have a simple class like customer that has these properties: - name, id, address, date of birth I would like to define some customer type objects in the managed-bean and initialize a table with those objects. So when the page is loaded it shows a table of pre-initialized customers. Is this doable. I am new (very new) to ...

69. Calling a backing bean method from onClick?

I have some HtmlGraphicImages (h:graphicImage) on a page and I'd like to give the user the ability to click on the images and have another web page brought up that shows a larger version of the image they clicked on. How can this be done? I know how to do it using a button (since it has an action event that ...

70. Bean from Bean

71. Bean Access

74. gettting managed bean names

75. JSF bean access in Java code

76. a href to call a backing bean impl?

I have a tag where I write out the response from a segment of code. writer.write(foo.getView()) where the getView() method returns "" I would like to have the on click invoke a backing bean method. In other words, I would like the foo.getView() method to return back a equivalent using Thanks.

77. Bean generated zip file to browser

78. Accessing a managed bean from within another managed bean

Hi, I'm just starting out using JSF and I'm a bit confused. I'm writing a web app that has very complex user roles and everything you do within the app needs to be determined by your user role. As a result all of my commandButtons and commandLinks point to methods of my managed user bean which determines whether the user can ...

79. How many backing bean?

81. Managed Bean Life cycle

82. recover application direcory from bean

84. managed -and backing beans question.

hi, here some uncertainties from my side: backing beans are related (->as model) to the components in a jsf-page (like swing beans). Does it mean, that per control and site(e.g. in bla.jsp) there exists one instance of a backing-bean, i.e. all jsp-tags (core&html) refer to one node in an ui-component tree of a site? it is not clear too, ...

86. Are managed-beans shared?

88. Backing bean vs Managed bean

Well, if you want to get really pedantic, a "Managed Bean" is a bean constructed/initialized via injection in the faces-config.xml file. A "Backing Bean" is a bean referenced by JSF pages and is defined in the faces-config.xml file. Few people will probably care about the difference. Usually if it's one, it's also the other.

89. Applet communicating with Managed Bean

There are two possibilities. 1. Use HTTP tunneling. This will require some sort of servlet to handle the actual communications with the bean, as neither http nor the servlet spec provide for direct access to Java session objects. A heavier variant of HTTP tunnelling is to implement a Web Service. 2. Use an RMI interface. Either raw RMI or an EJB. ...

90. kommunication between beans

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - ...

91. How to create managed beans at startup

I have some application-scoped managed beans that I'm defining in my faces config file. So far, so good, that's all standard. But I'd like them to be instanciated at application start-up, rather than later when they happen to be first referenced. Is there a standard way to trigger their creation at application start-up?

92. A Bit of Backing Bean Lifetime Confusion

Ok, say I have a backing bean and the scope is request. The form associated with said bean gets submitted. I know that a new instance of said bean is being created. So is it safe to assume or a true statement to say that the properties of said bean are persisted across the request but the bean object is not? ...

95. Trouble in calling a bean twice

96. Backing Bean query

I am having a screen in which all values being dislayed are stored in java backing bean. i have to code particular functionality under which whenever a person cliks OK button at end of screen a call needs to be made to server to compare current values on screen with stored value in backing beans. If values are different an alert ...

97. Not creating managed bean

98. Failing to do lookup in Backing Bean

99. Accessing a managed bean directly

Hi there, I'm new to Java web engineering, so please be patient. ) In my web application, there is a servlet that's transforming XML by XML to HTML. From the resulting web pages, I would like to update a shopping cart -- I was thinking of using AJAX to call a remote servlet or JSF page (without reloading the current user ...