-
1. Re: Practical Richfaces examples not working...
nbelaevski Dec 8, 2010 6:43 PM (in response to agustincarban)Agustin,
Can you please provide more details: what code do you use and what issues you are expecting?
-
2. Re: Practical Richfaces examples not working...
agustincarban Dec 8, 2010 7:30 PM (in response to nbelaevski)Right now... Wait a sec...
-
3. Re: Practical Richfaces examples not working...
agustincarban Dec 8, 2010 8:05 PM (in response to nbelaevski)The JSP File...
<h:form> <rich:panel style="width:450px;" > <f:facet name="header">Partial update</f:facet> <rich:dataGrid id="dataUser" value="#{user.userList}" var="theUser" columns="4" border="1" ajaxKeys="#{user.rowsToUpdate}"> <h:panelGrid id="userinfo"> <h:outputText value="#{theUser.name}" /> <h:outputText value="#{theUser.email}" /> <a4j:commandLink value="edit" onclick="#{rich:component('modalPanel')}.show()" reRender="edituserinfo"> <f:setPropertyActionListener value="#{theUser}" target="#{user.selectedUser}" /> </a4j:commandLink> </h:panelGrid> </rich:dataGrid> </rich:panel> </h:form> <rich:modalPanel id="modalPanel"> <f:facet name="header">Edit</f:facet> <a4j:keepAlive ajaxOnly="true" beanName="user" /> <h:form> <h:panelGrid id="edituserinfo" columns="2"> <h:outputText value="Name:" /> <h:inputText value="#{user.selectedUser.name}" /> <h:outputText value="Email" /> <h:inputText value="#{user.selectedUser.email}" /> </h:panelGrid> <h:panelGrid columns="2"> <a4j:commandLink value="Close" onclick="#{rich:component('modalPanel')}.hide()" /> <a4j:commandLink value="Save" actionListener="#{user.updateUser}" oncomplete="#{rich:component('modalPanel')}.hide()" reRender="userinfo" /> </h:panelGrid> </h:form> </rich:modalPanel>
And the Java Classess...
"user" Bean
import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.annotation.PostConstruct; import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; import javax.faces.event.ActionEvent; @ManagedBean(name="user") @RequestScoped public class UserBean { private List <User>userList; private User selectedUser; private Set <Integer>rowsToUpdate; @PostConstruct public void init () { userList = new ArrayList <User>(); for (int i=0; i<20; i++) { userList.add(new User("user","user@email.com")); } rowsToUpdate = new HashSet <Integer>(); } public User getSelectedUser() { return selectedUser; } public void setSelectedUser(User selectedUser) { this.selectedUser = selectedUser; } public List <User> getUserList() { return userList; } public void updateUser (ActionEvent event) { rowsToUpdate.clear(); int index = userList.indexOf(selectedUser); rowsToUpdate.add(index); } public Set<Integer> getRowsToUpdate() { return rowsToUpdate; } }
"userf" Bean
import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; @ManagedBean @RequestScoped /** * * @author Agustin */ public class User { private String name; private String email; public User() {} public User(String name, String email) { this.name = name; this.email = email; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
Well If you see the images... After clicking in edit and editing the details and clicking on save, it should update only the row where I clicked... But I don't get anything updated !!!... Hope I can get help from you or from another... Hope it doesn't take too much time !!!
-
richafaces.JPG 40.1 KB
-
-
4. Re: Practical Richfaces examples not working...
agustincarban Dec 9, 2010 10:46 AM (in response to agustincarban)Nick ?. It's working !!! ... I really don't know what I havetouched... Anyway, thanks for asnwering me... Heavinly Blessings !!!
-
5. Re: Practical Richfaces examples not working...
nbelaevski Dec 9, 2010 11:18 AM (in response to agustincarban)He-he, good I've noticed that sometimes JSF does not redeploy changed Facelets pages in runtime - so probably this can be the cause?
-
6. Re: Practical Richfaces examples not working...
agustincarban Dec 9, 2010 12:11 PM (in response to nbelaevski)Really don't know... But well here is a strange and weird thing that happened me often and previous before switching to this new example... I do my coding and when I try to run the project I get all the page in blank but If I remove some components, all the rest is display...
For instance...
<h:form id="form"> <rich:contextMenu attached="false" id="menu" submitMode="ajax"> <rich:menuItem value="Show #{auto.marca} - #{auto.modelo}" ajaxSingle="true"> <a4j:actionparam name="det" assignTo="#{listaAutos.selected}" value="#{auto}"/> </rich:menuItem> </rich:contextMenu> <h:panelGrid columns="2"> <rich:dataTable value="#{listaAutos.lista}" var="car" id="table" onRowMouseOver="this.style.backgroundColor='#F8F8F8'" onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'" rowClasses="cur"> <rich:column > <f:facet name="header"> <h:outputText value="Marca" /> </f:facet> <h:outputText value="#{car.marca}"/> </rich:column> <rich:column> <f:facet name="header"> <h:outputText value="Modelo" /> </f:facet> <h:outputText value="#{car.modelo}"/> </rich:column> <rich:column> <f:facet name="header"> <h:outputText value="Precio" /> </f:facet> <h:outputText value="#{car.precio}" /> </rich:column> <rich:componentControl event="onRowClick" for="menu" operation="show"> <f:setPropertyActionListener target="#{listaAutos.selected}" value="#{car}"/> <f:param value="#{car}" name="auto"/> </rich:componentControl> </rich:dataTable> <a4j:outputPanel ajaxRendered="true"> <rich:panel> <f:facet name="header"> <h:outputText value="Last Menu Action" /> </f:facet> <h:outputText value="#{listaAutos.selected.toString}"/> </rich:panel> </a4j:outputPanel> </h:panelGrid> </h:form>
If I remove the contextmenu, the outputpanel and the rich componentcontrol the datatable is display but If I leave one of these, nothing is display... Why is happenning this ? do u know ?
Thankx dfor the help