modalpanel and ajax action problem (rf 3.1.0)
grdzeli_kaci Aug 3, 2007 12:00 PMgood day.
i tried to use modal panel for editing datatable.
i have some input fields into the modal panel and fill them by onshow javascript event, after changes i have a4j:commandButton and trying to save changed fields, but i can't get values into backing bean. my code snippets :
1. view.xhtml (containing modal panel)
<h:form id="pageForm"> ......... (datatable view and so on..) </h:form> <h:form id="modalForm"> <a4j:region id="modalRegionId"> <modPanel:modalPanel id="mp" moveable="true" height="115" width="310" zindex="2000" onshow="document.getElementById('modalForm:prpNameModal').value=event.parameters.propName; document.getElementById('modalForm:prpIdModal').value=event.parameters.propId;"> <f:facet name="header"> <h:outputText value="Edit Properties" /> </f:facet> <f:facet name="controls"> <h:graphicImage value="/img/close.png" style="cursor:pointer" onclick="Richfaces.hideModalPanel('mp')" /> </f:facet> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td> <h:outputLabel for="prpIdModal">Property Id</h:outputLabel> </td> <td> <h:inputText id="prpIdModal" disabled="true" styleClass="inputfield" style="width:100%"/> </td> </tr> <tr><td style="height:5px;"></td></tr> <tr> <td> <h:outputLabel for="prpNameModal">Property Title</h:outputLabel> </td> <td> <h:inputText id="prpNameModal" value="#{property.propertyName}" styleClass="inputfield" style="width:100%"/> </td> </tr> <tr><td style="height:12px;"></td></tr> <tr> <td align="right" colspan="2"> <a4j:status id="submitStatusId" for="modalRegionId" startText="Saving ... " stopText=""> </a4j:status> <a4j:commandButton id="submitAdmModalWindow" reRender="blaaaaaaa,prop" action="#{propertyBean.editProperty}" oncomplete="windowclose();" value="Save"/> <input type="button" onclick="windowclose();" value="Cancel" /> </td> </tr> <tr> <td align="right" colspan="2"> <a4j:outputPanel ajaxRendered="true"> <h:messages id="modalError"/> </a4j:outputPanel> </td> </tr> </table> </modPanel:modalPanel> </a4j:region> <script language="javascript" type="text/javascript"> //<![CDATA[ var link = document.getElementById('modalForm:mpLastHref'); link.parentNode.removeChild(link); function windowclose(){ if (document.getElementById('modalForm:modalError')==null){ Richfaces.hideModalPanel('modalForm:mp'); }; }; //]]> </script> </h:form>
2. backing bean :
@Stateful @Name("propertyBean") public class PropertyManBean implements PropertyMan{ @PersistenceContext EntityManager em; @DataModel List<Property> properties; @DataModelSelection private Property selectedProperty; boolean propertyCount; @In(create=true) Property property; @In Identity identity; public List<Property> getProperties() { properties = (List<Property>)em.createNamedQuery("Property.findAll").getResultList(); setSize(properties.size()); return properties; } public void setProperties(List<Property> properties) { this.properties = properties; } public void editProperty(){ Users user = (Users)sessionContext.get("currentUser"); System.out.println("user = "+user); System.out.println("property = "+property); System.out.println("property = "+property.getPropertyName()); } public void removeProperty(){ System.out.println(selectedProperty); System.out.println(selectedProperty.getPropertyName()); System.out.println(selectedProperty.getId()); } public void addProperty(){ try { property.setRecStatus(new Long(1)); property.setRegDate(new java.sql.Date(System.currentTimeMillis())); property.setRemark("Property Parameter For User"); ................................................................................... em.persist(property); } catch (Exception e) { FacesMessages.instance().add("Could not Register. Please Trye Again"); } } @Remove @Destroy public void destroy() {} }
i have addproperty action outside modal panel and it works, but edit property into modal panel does not work, into backing bean, there is not property field values :(
i like modal panel component so much and want to use it.
can anybody help me ?
is there anything incorrect ?
__________________
Regards,
Paata