I need to send values from dialog to bean and insert these vales into the db. I can open the dialog but not able to send any parameter. My bean is
@Named(value = "service12")
@Dependent
public class Service {
private Teachers selectedTeacher;
public Service() {
}
public Teachers getSelectedTeacher() {
return selectedTeacher;
}
public void setSelectedTeacher(Teachers selectedTeacher) {
this.selectedTeacher = selectedTeacher;
}
public void getDialog(){
PrimeFaces current = PrimeFaces.current();
current.executeScript("PF('teacherDialog').show();");
}
public void test(){
Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
requestMap.put("teacher", selectedTeacher);
System.out.println(selectedTeacher.getFirstName());
}
} and the xhtml page:
<h:body>
<h:form id="teacherForm">
<p:growl id="msgs" showDetail="true"/>
<p:dataTable value="#{service.teacherList}" var = "teacherVar" editable="true" style="margin-bottom:20px" id ="t1" resizableColumns="true"
rows="10" paginator="true">
</p:dataTable>
<p:commandButton value="Add new row" styleClass="ui-priority-primary"
action="#{service12.getDialog}" />
</h:form>
<p:dialog id="dlgT" widgetVar="teacherDialog">
<h:form>
<p:panelGrid columns="2" >
<p:outputLabel value="First Name" />
<p:inputText id="tfn" value="#{service12.selectedTeacher.firstName}" />
<p:outputLabel value="Last Name" />
<p:inputText value="#{service12.selectedTeacher.lastName}" />
<p:outputLabel value="Account" />
<p:inputText value="#{service12.selectedTeacher.accountNo}" />
</p:panelGrid>
<p:commandButton value="Save" action="#{service12.test()}" oncomplete="PF('teacherDialog').hide();" process="@this">
</p:commandButton>
</h:form>
</p:dialog>
</h:body>
Can you tell me how to get the values from map?
Thank you.