Questions tagged [jsf-2]

JavaServer Faces (JSF) is a model-view-presenter framework typically used to create web applications. Version 2.x is a major step ahead compared to JSF 1.x, significantly expanding the standard set of components and component libraries.

JavaServer Faces 2.x is a major step ahead as compared to JSF 1.x, significantly expanding the standard set of components and component libraries. Facelets (which was designed specifically for JavaServer Faces) was adopted as the official view technology for JSF 2.x. This eliminates the life-cycle conflicts that existed with JSP, forcing workarounds by Java developers. Lot of things which are hardly possible in JSF 1.x can be done more elegantly in JSF 2.x.

For the real wiki, please jump over to the wiki: https://stackoverflow.com/tags/jsf/info.

15731 questions
110
votes
4 answers

How to use enum values in f:selectItem(s)

I want to make a selectOneMenu dropdown so I can select a status on my question. Is it possible to make the f:selectItem more flexible considering what happens if the order of the enums changes, and if the list was large? And could I do this better?…
LuckyLuke
  • 47,771
  • 85
  • 270
  • 434
110
votes
1 answer

When to use , tag files, composite components and/or custom components?

I started using JSF 2.0 with Facelets recently and got puzzled by new composite components knowing existing and other templating techniques offered by Facelets 1.x. What is the difference between those approaches? Functionally they…
mrembisz
  • 12,722
  • 7
  • 36
  • 32
106
votes
6 answers

Get JSF managed bean by name in any Servlet related class

I'm trying to write a custom servlet (for AJAX/JSON) in which I would like to reference my @ManagedBeans by name. I'm hoping to map: http://host/app/myBean/myProperty to: @ManagedBean(name="myBean") public class MyBean { public String…
Konrad Garus
  • 53,145
  • 43
  • 157
  • 230
104
votes
4 answers

How can I pass selected row to commandLink inside dataTable or ui:repeat?

I'm using Primefaces in a JSF 2 application. I have a , and instead of selecting rows, I want the user to be able to directly execute various actions on individual rows. For that, I have several s in the last column. My…
Michael Borgwardt
  • 342,105
  • 78
  • 482
  • 720
101
votes
2 answers

When to use f:viewAction / preRenderView versus PostConstruct?

When should one use the f:viewAction or preRenderView event to initialize data for a page versus using the @PostConstruct annotation? Is the rationale to use one or the other based on the type of scope of the backing bean e.g. If the backing bean is…
BestPractices
  • 12,738
  • 29
  • 96
  • 140
100
votes
5 answers

Error Parsing /page.xhtml: Error Traced[line: 42] The entity "nbsp" was referenced, but not declared

I'd like to use non breaking spaces in my JSF page. I know, in plain HTML I could use   for this and this works fine. However, when I put those   in a Facelets page, then it errors as follows: Error Parsing /page.xhtml: Error Traced[line:…
Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
95
votes
5 answers

How to provide a file download from a JSF backing bean?

Is there any way of providing a file download from a JSF backing bean action method? I have tried a lot of things. Main problem is that I cannot figure how to get the OutputStream of the response in order to write the file content to. I know how to…
zmeda
  • 2,909
  • 9
  • 36
  • 56
91
votes
1 answer

What is the use of faces-config.xml in JSF 2?

After the JSF 2 big support for annotations, I'm wondering what I would use the faces-config.xml for. What is its importance now? In other words, what are the configurations that can only be done through faces-config.xml and not via…
Mahmoud Saleh
  • 33,303
  • 119
  • 337
  • 498
91
votes
2 answers

When to use valueChangeListener or f:ajax listener?

What's the difference between the following two pieces of code - with regards to listener placement? and
Danijel
  • 8,198
  • 18
  • 69
  • 133
82
votes
5 answers

What are the differences between ${} and #{}?

I'm programming in JSF2 and NetBeans creates many pages with #{} that contains an expression. However sometimes on the web I found ${} for the same thing! Are there any differences? What are they?
Filippo1980
  • 2,745
  • 5
  • 30
  • 44
81
votes
2 answers

How does the 'binding' attribute work in JSF? When and how should it be used?

There are lot of materials out there differentiating value attribute and binding attribute in JSF. I'm interested in how both approaches differ from each other. Given: public class User { private String name; private UICommand link; //…
John Eipe
  • 10,922
  • 24
  • 72
  • 114
78
votes
5 answers

Difference between h:button and h:commandButton

In JSF 2, what is the difference between h:button and h:commandButton ?
Geek
  • 26,489
  • 43
  • 149
  • 227
75
votes
1 answer

Difference between View and Request scope in managed beans

What does the view scope mean? Can anyone explain about it, so that I can understand how it differs from the request scope?
Maddy
  • 3,726
  • 9
  • 41
  • 55
67
votes
1 answer

Which XHTML files do I need to put in /WEB-INF and which not?

After these questions: https://stackoverflow.com/questions/8589315/jsf2-dynamic-template Dynamic ui:include How can I retrieve an object on @WindowScoped? How can I check if an object stored with @WindowScoped is stored correctly? ICE Faces and…
Filippo1980
  • 2,745
  • 5
  • 30
  • 44
67
votes
3 answers

What is Mojarra?

How is Mojarra different from Sun's JSF Reference Implemenation? Is it just a later version? Is it simply a rename?
JeffJak
  • 2,008
  • 5
  • 28
  • 40