• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Trying to refresh a dataTable on a JSP after data is updated but so far no luck

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Saloon Keeper
Posts: 28486
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Randall!

All that JSP stuff is way obsolete, especially the taglib stuff. So sooner or later, a rewrite is almost inevitable. Worse yet, it has scriptlets in it!

You can make things a lot easier on our eyes: https://coderanch.com/how-to/java/UseCodeTags

What I can read, however, makes it look likely that not only was this stuff written quite a while back, the person doing it didn't understand JSF very well.
 
Randall Carver
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Tim, it sounds like I should just rewrite the app.

Can you recommend a site which might be helpful for writing a database CRUD application using JSF/RichFaces/AJAX? Currently we are using JBoss 5.1.0.GA web server , MySQL database and using the NetBeans 7.0.1 IDE.

Thanks Again, Randy
 
Randall Carver
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately prior to rewriting the application we will need to try and get the re rendering of the dataTable in the form working. Please let me know if you see any way of getting this working and/or what you would need from me to hopefully assist.

Thanks, Randy
 
Tim Holloway
Saloon Keeper
Posts: 28486
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's a little more work than I could do for free.

I do most of my CRUD webapps these days using JSF2/JPA/Spring with RichFaces providing most of the AJAX support and they work fine in Tomcat6 or higher. JBoss is perfectly fine as is GlassFish.

I learned some very painful and expensive lessions about becoming dependent on an IDE, so while I use an IDE (which one doesn't matter) for editing and development, my serious stuff is built offline using Maven. Maven is also useful in that it can use archetypes to set up the core project files and even the IDE support files, at least for Eclipse and IntelliJ. I don't know if anyone has done a Maven option for NetBeans or not. Since I use an ORM, I'm also fairly agnostic about what brand of database is backing the webapp.
 
Randall Carver
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim, I completely understand. I thought maybe if you saw something simple that was being done wrong that would actually make it work.

At this point I believe my recommendation to management will be to do a complete rewrite of the application so we can get the requested functionality working properly.

Thanks Again,
Randy
 
The City calls upon her steadfast protectors. Now for a tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic