You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by an...@magnasteyr.com on 2006/01/26 14:10:00 UTC

Problems with ValueChangeEvent and ValueBinding

Hi all!

In my application I have a inputText Component with a ValueChangeEvent.
The ValueChangeMethod starts a Database query and if some data is found, then the founded records are written into other inputText Components on the mask.

The problem now is, that if I add a ValueBinding attribute to this other inputText fields, the new data from the query isn't written into the fields. If I remove the Valuebinding everything works...
How can I overcome this problem?

Here my jsp with two InputText Fields
<t:htmlTag value="td" rendered="#{showTags.showLfnr}">
	<h:inputText binding="#{beziehungsDto.ITlfnr}"  id="lfnr"
		value="#{beziehungsDto.lfnr}" styleClass="mustfield" required="true"
		size="35" rendered="#{showTags.showLfnr}" immediate="true"
		valueChangeListener="#{querySelectHelper.selectSamData}"
		onchange="submit()">
		<f:validateLength maximum="35"></f:validateLength>
	</h:inputText>
</t:htmlTag>

In this second field some data should be written. If I remove the binding attribute, it works, if I leave it, the field isn't updated...
<t:htmlTag value="td">
	<h:inputText binding="#{beziehungsDto.ITpartnername}" id="partnernameneu" value="#{beziehungsDto.namepartner}"
	styleClass="mustfield" required="true" size="35">
		<f:validateLength maximum="35"></f:validateLength>
	</h:inputText>
</t:htmlTag>


Here is the ValueChangeMethod:

public void selectSamData(ValueChangeEvent event)
	{
		beziehungsDto = (BeziehungDto)FacesUtil.getManagedBean("beziehungsDto");
		qh = (QueryHelper)FacesUtil.getManagedBean("queryHelper");
		Session session = HibernateSAMUtil.currentSession();
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
			String sqlstring = "Select a.firmNr, a.firmNamKurz, a.bdtKndNr," +
					" a.lfvUebArt, a.sfDunsNr from Eklist a  where a.firmNr=:liefnr";
			
			Query q =session.createQuery(sqlstring);

			q.setString("liefnr", (String)event.getNewValue());
			
			Iterator it = q.list().iterator();
			while(it.hasNext())
			{
				Object[] row = (Object[])it.next();
				
				//beziehungsDto.setNamepartner((String)row[1]);
				beziehungsDto.getITpartnername().setValue((String)row[1]);
				beziehungsDto.setNamepartner((String)row[1]);
...
				
				}
			
			}
			
			String viewId = "/popupAddBeziehung.jsp";
			FacesContext context = FacesContext.getCurrentInstance();
			UIViewRoot view = context.getApplication().getViewHandler()
					.createView(context, viewId);
			view.setViewId(viewId);
			context.setViewRoot(view);
			context.renderResponse();
					
			tx.commit();
		}
		catch (Exception ex) {
			if (tx != null)
				tx.rollback();

			MessageUtils.addMessage(FacesMessage.SEVERITY_WARN,
					"errorListDataForAdminDB", null, context);// TODO
			ex.printStackTrace();
		}
		finally {
			HibernateSAMUtil.closeSession();
		}

			
	}


______________________________________________________________________

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. 
______________________________________________________________________