Problem after Update database table
richfaceman May 16, 2010 12:44 AMHi All
I hope someone can help me, I have a <rich:scrollableDataTable> where by double clicking on a row, a ModePanel opens up with relevent values so that it can be updated. The problem is when one record is updated / saved and you click on a different row the Panel opens up with the same values as you last updated. It's been two very long days can someone help please. There are NO errors as such.
Thanks
Zed
JSP/JSF Page
<rich:scrollableDataTable rowKeyVar="rkv" width="775px" height="140px"
id="notes" rows="40" columnClasses="col" value="#{noteBean.noteList}"
var="noteData" rowClasses="r2, r3">
<a4j:support event="onRowDblClick" oncomplete="#{rich:component('UpdatePanel')}.show();" reRender="UpdatePanel">
<f:setPropertyActionListener value="#{noteData}" target="#{noteBean.selectedNote}" />
</a4j:support>
<rich:modalPanel id="UpdatePanel" autosized="true" headerClass="home_tabNote" >
<f:facet name="header">
<h:panelGroup>
<h:outputLabel value="Add Note" ></h:outputLabel>
</h:panelGroup>
</f:facet>
<h:form>
<h:panelGrid columns="3">
<h:outputLabel for="title" value="Title"></h:outputLabel>
<rich:spacer width="10px"></rich:spacer>
<h:inputText id="title" value="#{noteBean.selectedNote.title}"
size="52"></h:inputText>
<rich:spacer style='display:block'></rich:spacer>
</h:panelGrid>
<h:panelGrid columns="3">
<h:outputLabel for="descr" value="Note"></h:outputLabel>
<rich:spacer width="10px"></rich:spacer>
<h:inputTextarea id="descr" value="#{noteBean.selectedNote.descr}"
cols="40" rows="10"></h:inputTextarea>
<rich:spacer style='display:block'></rich:spacer>
</h:panelGrid>
<h:panelGrid columns="3">
<a href="#" onclick="javascript:Richfaces.hideModalPanel('UpdatePanel'); return false;">Cancel</a>
<rich:spacer width="320px" />
<a4j:commandLink action="#{noteBean.updateNote}"
oncomplete="#{rich:component('UpdatePanel')}.hide()"
title="Save changes" reRender="UpdatePanel,notes">Save
</a4j:commandLink>
</h:panelGrid>
</h:form>
</rich:modalPanel>
/*********************************************************************** Bean file ****************************************/
private NoteDetails selectedNote;
private ArrayList<NoteDetails> noteList;
getters & setters here.
public void updateNote(){
try {
// Load the database driver
Class.forName("oracle.jdbc.OracleDriver");
// Get a Connection to the database
connection = DriverManager.getConnection(connectionURL, "user","psw");
proc = connection
.prepareCall("{call pa_persorg.pr_upd_note(?,?,?,?)}");
proc.setInt(1, selectedNote.getNote_id());
proc.setString(2, selectedNote.getTitle());
proc.setString(3, selectedNote.getDescr());
proc.registerOutParameter(4, OracleTypes.VARCHAR);
proc.execute();
proc.close();
}
catch (ClassNotFoundException e) {
System.out.println("Couldn't load database driver: " + e.getMessage());
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}//end of updateNote method