Need some assitance on how to get an embedded form refreshed when a record is added or deleted in a
JSP form in a
JSF application. The main jsp form has an embedded login form, embedded add/edit form and the embedded form with the dataTablerefresh an embedded form containing a dataTable displaying the records in the DB. The Add, Edit and Delete seem to work on the backend because the database gets updated but the embedded form with the dataTable does not. I tried several thing, like an AJAX rerender on the dataTable but so far no luck.
Below is the JSP code. I took this over from a developer who left the organization and I'm attampting to get the functionality requested working without rewriting the whole thing. Please let me know if you need any additional information.
Thanks, REC
<%@page import="org.ccf.itci.xBeans.adminBean"%>
<%@page import="org.ccf.itci.xBeans.ddlBean"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j"%>
<%@taglib prefix="rich" uri="http://richfaces.org/rich"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<!--[IF lte IE 7]>
<link href="css/IE7.css" type="text/css" rel="Stylesheet" />
<![endif]-->
<!--[if !IE]><!-->
<link href="css/styles.css" type="text/css" rel="Stylesheet" />
<!--<![endif]-->
<!--[if gt IE 7]>
<link href="css/styles.css" type="text/css" rel="Stylesheet" />
<![endif]-->
<%
response.setHeader("Cache-control", "no-store");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", -1);
adminBean ldp = new adminBean();
//ldp.setIpaddress(request.getRemoteAddr());
ldp.setIpaddress(request.getRemoteHost());
%>
</head>
<body style="background-image: -webkit-gradient(linear, left top, right top, color-stop(0, #D6E7F5), color-stop(1, #223A54));
filter: progid:DXImageTransform.Microsoft.gradient(enabled='true', GradientType=1 startColorstr='#D6E7F5', endColorstr='#223A54'); MARGIN: 1px; FONT-FAMILY: Arial, Verdana, Helvetica, sans-serif; BACKGROUND: #d6e7f5; FONT-SIZE: 8pt; OVERFLOW: hidden; TOP: 1px; FONT-WEIGHT: 900;
background-image: -moz-linear-gradient(left, #D6E7F5 0%, #223A54 100%);">
<script type="text/javascript" src="scripts/methods.js"></script>
<script type="text/javascript" src="scripts/jquery.js"></script>
<center>
<label class="ddllabel"></label>
<h:form id="panels" rendered="#{!adminBean.loggedIn}">
<h:panelGrid columns="1" width="30%" frame="border" border="6" cellpadding="6" cellspacing="4" >
<center>
<h:panelGrid columns="2" width="100%" frame="border" border="0">
<center>
<label align="right" class="adminlabel">Username:</label>
<h:inputText styleClass="slctadmin" id="username" required="true" binding="#{adminBean.username}"/>
<label class="adminlabel">Password:</label>
<h:inputSecret styleClass="slctadmin" id="password" required="true" binding="#{adminBean.password}" />
</center>
</h:panelGrid>
<h:panelGrid columns="1" width="100%" frame="border" border="0">
<center>
<h:commandButton styleClass="adminbutton" value="Login" id="btnLogin" action="#{adminBean.ldapAuth}" />
</center>
</h:panelGrid>
</center>
</h:panelGrid>
</h:form>
</center>
<div style="float:left;">
<h:form id="dropdowns" styleClass="position" rendered="#{adminBean.loggedIn}">
<h1 id="header1">
<table >
</table>
</h1>
<h:panelGrid columns="2">
<label class="ddllabel">IP Address:</label>
<h:inputText styleClass="slct1" id="pcIpAddress" required="false" binding="#{adminBean.pcIpAddress}"/>
<label class="ddllabel">PC Location:</label>
<h:inputText styleClass="slct1" style="width:300px" id="pcName" required="false" binding="#{adminBean.pcName}"/>
<label class="ddllabel">Facility:</label>
<h:selectOneMenu styleClass="slct1" immediate="true" id="facility" value="#{ddlBean.selectedFacility}" onchange="this.form.submit()"
valueChangeListener="#{ddlBean.facilities_processValueChange}">
<f:selectItems value="#{ddlBean.facilities}"/>
</h:selectOneMenu>
<label class="ddllabel">Department:</label>
<h:selectOneMenu styleClass="slct2" immediate="true" id="department" value="#{ddlBean.selectedDepartment}" onchange="this.form.submit()"
valueChangeListener="#{ddlBean.departments_processValueChange}">
<f:selectItems value="#{ddlBean.departments}"/>
</h:selectOneMenu>
<label class="ddllabel">
Unit:</label>
<h:selectOneMenu styleClass="slct2" immediate="true" id="unit" value="#{ddlBean.selectedUnit}" onchange="this.form.submit()"
valueChangeListener="#{ddlBean.units_processValueChange}">
<f:selectItems value="#{ddlBean.units}"/>
</h:selectOneMenu>
<label class="ddllabel">Comments:</label>
<h:inputTextarea styleClass="slct1" style="width:200px" id="comments" binding="#{adminBean.comments}"/>
<%if (ddlBean.department == null && ddlBean.unit == null) {%>
<button class="adminbutton; width: 100px" disabled>Submit</button>
<%} else {%>
<a4j:commandButton id="btnSubmit" styleClass="adminbutton; width: 100px" value="New Submit" onclick="javascript:validateForm()" reRender="devicetable:device" action="#{adminBean.submitControlledDevice}"/>
<%}%>
<tr></tr>
<h:commandButton id="lnkLogout" styleClass="adminbutton; width: 100px" value="Logout" onclick="javascript:resetadmin()" action="#{adminBean.ldapLogOut}" />
</h:panelGrid>
</h:form>
</div>
<div style="padding-left: 30px; height: 500px; width: 750px; overflow:auto">
<a4j:form id="devicetable" styleClass="position" rendered="#{adminBean.loggedIn}">
<rich:panel header="PC Listing" style="width: 700px">
<h:panelGroup id="devices" >
<h:dataTable id="device" value="#{adminBean.devices}" rules="all" var="dev" frame="border">
<h:column>
<f:facet name="header" >
<h:outputText value="IP Address"/>
</f:facet>
<h:outputText value="#{dev.clientIP}"/>
</h:column>
<h:column>
<f:facet name="header" >
<h:outputText value="PC Location"/>
</f:facet>
<h:outputText style="width:500px;"value="#{dev.pcName}"/>
</h:column>
<h:column>
<f:facet name="header" >
<h:outputText value="Facility"/>
</f:facet>
<h:outputText value="#{dev.facility}"/>
</h:column>
<h:column>
<f:facet name="header" >
<h:outputText value="Department"/>
</f:facet>
<h:outputText value="#{dev.department}"/>
</h:column>
<h:column>
<f:facet name="header" >
<h:outputText value="Unit"/>
</f:facet>
<h:outputText value="#{dev.unit}"/>
</h:column>
<h:column>
<f:facet name="header" >
<h:outputText style="width:800px;" value="Comments"/>
</f:facet>
<h:outputText style="width:800px;" value="#{dev.comments}"/>
</h:column>
<h:column rendered="true">
<f:facet name="header" >
<h:outputText value="Delete"/>
</f:facet>
<a4j:commandButton id="btnDelete" styleClass="adminbutton" value="Delete" onclick="javascript:return deleteAlert('#{dev.clientIP}');" action="#{adminBean.delete}" reRender="devicetable:device" >
<f:setPropertyActionListener target="#{adminBean.propertyName1}" value="#{dev.clientIP}" />
<f:setPropertyActionListener target="#{adminBean.propertyName2}" value="propertyValue2" />
</a4j:commandButton>
</h:column>
<h:column rendered="true">
<f:facet name="header" >
<h:outputText value="Edit"/>
</f:facet>
<h:commandButton id="btnEdit" styleClass="adminbutton" value="Edit" action="#{adminBean.getEditParams}">
<f:setPropertyActionListener target="#{adminBean.propertyName1}" value="#{dev.clientIP}" />
<f:setPropertyActionListener target="#{adminBean.propertyName2}" value="propertyValue2" />
</h:commandButton>
</h:column>
</h:dataTable>
</h:panelGroup>
</rich:panel>
</a4j:form>
</div>
</body>
</html>
</f:view>