An Introduction To JBoss RichFaces
Creating user interface
In the WebContent folder, create a page called user.xhtml with the following content:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<head>
<title>RichFaces</title>
</head>
<body>
<h:form>
<rich:panel>
<f:facet name="header">
Just some users
</f:facet>
<rich:dataTable value="#{userBean.users}" var="user">
<h:column>
<h:outputText id="name" value="#{user.name}"/>
</h:column>
<h:column>
<h:outputText id="email" value="#{user.email}"/>
</h:column>
</rich:dataTable>
</rich:panel>
</h:form>
</body>
</html>
The page is also very simple. We just display all the users we created inside the managed bean using the rich:dataTable component. At this point we are ready to test the application.
Running on a server
1. Make sure everything is saved.
2. In Servers view, right click the server and select Start
3. Right click users.xhtml and select Run As/Run on Server
4. Click Finish
A Web browser window should open displaying users in a table.
The next step is to add a button to each column, which when clicked will open a modal panel with user details.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)






Comments
Max Katz replied on Mon, 2009/02/16 - 9:48pm
in response to:
Harshad Khasnis
Max Katz replied on Mon, 2009/02/16 - 9:51pm
in response to:
Asma Shah
nancy xiao replied on Mon, 2009/02/16 - 10:24pm
nancy xiao replied on Mon, 2009/02/16 - 10:24pm
nancy xiao replied on Mon, 2009/02/16 - 10:24pm
Thai Dang Vu replied on Sat, 2009/02/21 - 7:20am
I have a question:
Your "Save" link is in the form in the modal panel and it's going to re-render the columns "name" and "email" which are in another form. How can RichFaces know which form that has the "name" and "email" columns to re-render?
Max Katz replied on Mon, 2009/02/23 - 5:44pm
in response to:
Thai Dang Vu
It first searches the current naming container (form), then it searches the parent container and so on. At some point it will reach the root and search from there.
You can see the full algorithm here: org.ajax4jsf.renderkit.RendererUtils.findComponentFor(UIComponent, String)
Tom Schurmans replied on Wed, 2009/03/04 - 5:56am
Unexpected error processing managed bean userBean com.sun.faces.mgbean.ManagedBeanPreProcessingException: Unexpected error processing managed bean userBean at com.sun.faces.mgbean.BeanManager.preProcessBean(BeanManager.java:356) at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:201) ...
Caused by: com.sun.faces.mgbean.ManagedBeanPreProcessingException: Unexpected error processing managed property users ...
Caused by: java.lang.NullPointerException at com.sun.faces.mgbean.ManagedBeanBuilder.bakeBeanProperty(ManagedBeanBuilder.java:350) at com.sun.faces.mgbean.ManagedBeanBuilder.bake(ManagedBeanBuilder.java:107) ... 59 more
Any thoughts?
btw, the zip file you included doesn't work here. And the alternative doesn't give the extra "jsf + richfaces option" when you start a new eclipse project. Any chance you can rezip it and upload it somewhere else?
Thanks!
Max Katz replied on Sat, 2009/03/07 - 12:45am
in response to:
Tom Schurmans
@TomSch: You might have an error in Faces config file, can you post it here? As for the zip file, I'll try to upload a new or post a link on my blog.
Jean Chastain replied on Fri, 2009/03/20 - 9:27am
in response to:
Max Katz
Max, I know you're a busy guy, but I want to pick up this thread. I'm running on JBoss 5.0 and have the same problem shahasma99 is having. After the first deploy (before the modal panel is added), all I see it the title. I do have the @PostConstruct before the init(), but when I set a breakpoint on the init(), it doesn't seem to be getting there. Is there some JBoss configuration I'm missing? Or is it just not possible to break there?
TIA, Jean
Kannan Varadharajan replied on Fri, 2009/04/03 - 7:48am
Alex Cbbdjfkdjfkj replied on Fri, 2009/04/03 - 10:26am
Max Katz replied on Thu, 2009/04/09 - 10:32pm
in response to:
Jean Chastain
Max Katz replied on Thu, 2009/04/09 - 10:32pm
in response to:
Kannan Varadharajan
Max Katz replied on Thu, 2009/04/09 - 10:34pm
in response to:
Alex Cbbdjfkdjfkj
Davut Uysal replied on Fri, 2009/04/17 - 2:21am
Nghia Le replied on Mon, 2009/04/27 - 3:41pm
Nick Thomson replied on Thu, 2009/04/30 - 9:36am
Hi Maxkatz,
I'm trying to use the ajaxKeys options with a dataTable as you have described in the article and I've got it working with the dataTable and even using the dataScroller control.
However, once I enable sorting in the data table, the rows do not refresh properly. If the items are sorted in the same order as they are in the List the correct rows are redrawn, but sorting them in any other order results in the required rows not being highlighted.
I'm using Seam 2.1.1.GA and RichFaces 3.3.0.GA, the table looks like this (the keepalive is included but not shown and I've removed some of the columns)..
<rich:dataTable id="testDataTable" value="#{testBean.data}" var="data" ajaxKeys="#{testBean.ajaxKeys}" sortMode="single" rows="20">
<rich:column sortBy="#{data.id}" id="pid" style="#{data.viewing ? 'background: red' : '' }">
<f:facet name="header">
<h:outputText value="ID"/>
</f:facet>
<a4j:commandLink style="display: block; width: 100%;" action="#{testBean.SelectView(data)}" value="#{data.id}" reRender="pid,param1"/>
</rich:column>
<rich:column sortBy="#{data.testParam1}" id="param1" style="#{data.viewing ? 'background: red' : '' }">
<f:facet name="header">
<h:outputText value="Param 1"/>
</f:facet>
<a4j:commandLink style="display: block; width: 100%;" action="#{testBean.SelectView(data)}" value="#{data.testParam1}" reRender="pid,param1"/>
</rich:column>
</rich:dataTable>
And the appropriate bits from the testBean..
Any idea how to fix this?
Thanks,
Nick
Alex Cbbdjfkdjfkj replied on Tue, 2009/05/05 - 9:53am
For those having difficulty (like me!) with the step that says "For JSF environment, select JSF 1.2, Facelets, RichFaces", try this:
- After downloading the template zip file, DON'T just copy and paste the folders into the jboss template folder!
- Copy the richfaces-template-6.zip\lib\jsf-1.2-facelets-richfaces\ to your Eclipse's appropriate folder (for me, it's here: C:\eclipse_ide\plugins\org.jboss.tools.common.projecttemplates_3.0.0.GA-R200903141626-H5\lib)
- Copy the \templates\jsf-1.2-facelets-richfaces\ to your Eclipse folder (something like C:\eclipse_ide\plugins\org.jboss.tools.common.projecttemplates_3.0.0.GA-R200903141626-H5\templates)
- And don't forget the \templates\pages\jsf\
- In other words, you need to go into each downloaded item and copy its contents over to the matching folder on your jboss installation.
If you don't see the RichFaces item in the Eclipse dropdown, then you didn't copy the items over correctly. Try again. Believe it or not, this step messed me up! I finally see that item in the dropdown box and can proceed with the tutorial!Max Katz replied on Tue, 2009/05/05 - 12:13pm
in response to:
Davut Uysal
Max Katz replied on Tue, 2009/05/05 - 12:15pm
in response to:
Nghia Le
Max Katz replied on Tue, 2009/05/05 - 12:18pm
in response to:
Nick Thomson
Max Katz replied on Tue, 2009/05/05 - 12:20pm
Davut Uysal replied on Wed, 2009/05/06 - 12:57pm
in response to:
Max Katz
Debraj Ganguly replied on Sat, 2009/05/09 - 7:56am
I have a page which has a link to open a modal panel (BasePage.jsp)
h:form
..............
..............
a href="#" onclick="#{rich:component(modal_panel)}.show()">#{msg.ShowPanel}/a
...........
.........
/h:form
I am including the modal panel page in the base page after this in a separate form
h:form
ui:include src="MyModalPanel.jsp" /
h:form
MyModalPanel.jsp
----------------------
In this page I have a tab containing a number of and elements.
I also have a a4j:commandButton at the end. I have an action defined for the button.
a4j:commandButton id="save_form" value="Save" image="../../images/Save_bttn.jpg"
action="#{baseBean.save}" reRender="validation_messages_add" ajaxSingle="false" /
I am reRendering the validation message.
My problem
--------------
on clicking the save button the baseBean.save() method is called correctly but the bean is not getting reflected with the user entered value. It still hold the initialized values that i had in the base bean attrib definition.
I changed the a4j:commandButton to h:commandButton and also added the onclick function to hide the modal. I had no problem then but this closed the modal panel and the validation messages on the panle could not be viewed by the user.(page refreshed.)
Can you please guide me why the a4j:commandButton thing is unable to get the form values.
waiting for your reply,
thanks in advance
(I have purposefully ommited the '<' and '>' tags
Annie Cheng replied on Thu, 2009/05/14 - 11:20am
Max Katz replied on Tue, 2009/05/19 - 5:45pm
in response to:
Debraj Ganguly
Sorry, I don't understand the problem. Where is the input field? I'm also surpised that this works, that's JSP with Facelets...:
<ui:include src="MyModalPanel.jsp" />
Max Katz replied on Tue, 2009/05/19 - 5:46pm
in response to:
Annie Cheng
hookfi john replied on Sun, 2009/05/31 - 7:48am
jame jack replied on Mon, 2009/06/29 - 4:23pm