|
JSF Application |
|
<f:selectItems
value=”#{backingBean.songList}”/>
</h:selectOneMenu>
</br>
<h:outputText id=”result”
value=”#{backingBean.songDetail}”/>
</br></br>
<h:selectOneRadio id=”catId”
value=”#{backingBean.category}”
immediate=”true” onclick=”submit()”
valueChangeListener=
”#{backingBean.processValueChange2}”>
<f:selectItems
value=”#{backingBean.categories}”/>
</h:selectOneRadio>
<h:selectOneListbox id=”subcategory”
value=”#{backingBean.subCategory}”
binding=”#{backingBean.subCategoryList}”
rendered = “false”>
<f:selectItems
value=”#{backingBean.subCategories}”/>
</h:selectOneListbox>
</br></br>
<h:commandButton id=”cb” value=”Show
All Selected” immediate=”true”
actionListener=
”#{backingBean.processActionShow}”/>
</br>
<h:outputText id=”showValue”
binding=”#{backingBean.showAllSelected}”
rendered=”true”/>
</h:form>
</f:view>
</body>
</html>
In the above code, you can see that immediate
attribute is set to “true” i.e. handle the events
for the component in the apply request values
phase rather than the invoke application phase.
JavaScript code is used to process the value
change event immediately when the user makes
a change. Component generating action event
doesn’t require this support so there is no need
to write JavaScript code to submit the
component for processing.
The event handler methods:
The value change event handler method for the |
|
component used for selection of the song is
processValueChange1() which has been
mentioned in the attribute valueChangeListener.
valueChangeListener=
”#{backingBean.processValueChange1}”
The value change event handler method for
the component used for selection of category
is processValueChange2() which has been
mentioned in the attribute
valueChangeListener.
valueChangeListener=
”#{backingBean.processValueChange2}”>
The action event handler method for the
component used to show all selected items is
processActionShow() which has been
mentioned in the attribute actionListener.
actionListener=”#{backingBean.processActionShow}”
Backing Bean:
Backing bean named “Bean.java” implements
event handler methods. It’s code is given
below:
Bean.java
package javajazzup;
import java.util.*;
import javax.faces.component.*;
import
javax.faces.component.html.HtmlOutputText;
import
javax.faces.component.html.HtmlSelectOneListbox;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
public class Bean{
// Stores song titles
ArrayList songList;
|
|
|
|
|
Feb
2008 | Java Jazz Up | 55 |
|
|
View All Topics |
All Pages of this Issue |
Pages:
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53 ,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63 ,
64,
65 ,
66 ,
67 ,
68 ,
69 ,
70 ,
71 ,
72 ,
Download PDF |
|
|
|
|
|
|
|
|
|