In this form I have different JSF InputtextBoxes. When the user enters a string into the first InputTextBox a ValueChangeListener is evoked. This ValueChangeListener is binded to a method, with takes the entered String and starts a database query. If data is found in the database I now want to display these data in the other inputTextBoxes of the form. The other InputTextBoxes have a value binding.
My problem now is, that I don’t know how to tell JSF to reload the page so that the Data of the Database query is displayed in the other InputTextBoxes.
I have already tried to add a _javascript_ funktion: window.location.reload to the onchange Event, but it doesn't help.
<td><h:inputText id="gateway" value="#{newPartnerDto.gwname}"
size="30" styleClass="mustfield" title="#{msg.gateway}"
valueChangeListener="#{newPartnerDto.selectgateway}"
onchange="submit();window.location.reload();" immediate="true"/></td>
Here is one of the other InputBoxes:
<
td><h:inputText id="msfid" value="#{newPartnerDto.mandsfid}"size="30"
styleClass="search"
title="#{msg.msfid}" /></td>
Here is my database query (With Hibernate)
public void selectgateway(ValueChangeEvent event)
throws Exception {
System.out.println("SelectGateway
ValueChange");
String value = (String) event.getNewValue();
Session session =
HibernateUtil.currentSession();
Transaction tx =
null;
try {
tx =
session.beginTransaction();
String sqlstring = "Select
eg.gwId, eg.aId,eg.aId.method, eg.rId,"
+ "
eg.rId.router, eg.gwName, eg.ssid, eg.sfid,
eg.pwd,"
+ " eg.mandSsid, eg.mandSfid,
eg.mandPwd, eg.phonenumber,"
+ " eg.ip,
eg.checkNumber, eg.calluserdata from EtGateway
eg"
+ " where
eg.gwName=:gwName";
Query q =
session.createQuery(sqlstring);
q.setString("gwName",
value);
querylist =
q.list();
Iterator i = querylist.iterator();
while (i.hasNext())
{
Object[] row = (Object[])
i.next();
gwid = (Long) row[0];
EtAccessMethod eam =
(EtAccessMethod) row[1];
aid =
eam.getaId();
amethod = (String)
row[2];
EtRouter er = (EtRouter)
row[3];
rid =
er.getrId();
router = (String)
row[4];
gwname = (String)
row[5];
ssid = (String)
row[6];
sfid = (String)
row[7];
pwd = (String)
row[8];
mandssid = (String)
row[9];
mandsfid = (String)
row[10];
mandpwd = (String)
row[11];
rufnummer = (String)
row[12];
ip = (String)
row[13];
checknumber = (Long)
row[14];
if (checknumber.compareTo(new
Long(1)) == 0) {
System.out.println("****
CHECKNUMBER =1");
this.b_checknumber = new
Boolean(true);
}
calluserdata = (Long)
row[15];
if (calluserdata.compareTo(new Long(1)) ==
0) {
this.b_calluserdata = new
Boolean(true);
}
}
tx.commit();
}
catch (Exception ex)
{
if (tx !=
null)
tx.rollback();
msg =
bundle.getString("errorlistGateway");
context.addMessage(null,
new FacesMessage(
FacesMessage.SEVERITY_WARN,
msg, null));
throw
ex;
}
finally
{
HibernateUtil.closeSession();
}
}
Thx for helping!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify your system manager. This footnote also confirms that this email message has been swept for the presence of computer viruses. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

