Jeff

 

1)

Shouldn’t this

ctxt.getExternalContext().getSessionMap().put(“SHOWTHIS”, “partNumber”);

be

ctxt.getExternalContext().getSessionMap().put( “partNumber”, “SHOWTHIS”);

 

surely the component id is the key

 

2)

You could use something like

<h:inputText id="partNumber"

value="#{nonConformingMaterial.partNumber}" required="true" immediate="true"

onchange="submit()"valueChangeListener=”#{nonConformingMaterial. processValueChange” />

 

so you would move

public void processValueChange(ValueChangeEvent vce) throws AbortProcessingException  {

into your backing bean class

and then your code would have direct access to the getter/setter methods

 

getPartNumber() & setPartNumber()

so your code could

 

public void processValueChange(ValueChangeEvent vce) throws AbortProcessingException  {

String partNo = ((String)vce.getNewValue());

System.out.println("A value has changed!" + partNo);

 

setPartNumber(partNo);

FacesContext ctxt =  FacesContext.getCurrentInstance();

ctxt.renderResponse();

}

 

3)

The doesn’t fire until the component loses focus

 

If this is NOT OK then you should consider using  

 

 

Stefan Maric | IT & Professional Services | BT Global Services

E: [EMAIL PROTECTED]  |  www.bt.com/globalservices

 

This electronic message contains information from British Telecommunications plc, which may be privileged

or confidential.  The information is intended for use only by the individual(s) or entity named above.  If you

are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of

this information is strictly prohibited.  If you have received this electronic message in error, please notify

me by telephone or email (to the number or email address above) immediately.

 

Activity and use of the British Telecommunications plc e-mail system is monitored to secure its effective

operation and for other lawful business purposes. Communications using this system will also be monitored

and may be recorded to secure effective operation and for other lawful business purposes.

 

British Telecommunications plc. Registered office:  81 Newgate Street London EC1A 7AJ   Registered in

England no:  1800000

size=2 width="100%" align=center tabindex=-1>

From: Jeffrey Porter [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 25, 2005 4:04 PM
To: MyFaces Discussion
Subject: Help still needed with valueChangeListener

 

 

 

I have the code that calls my ValueChangeListener implementation.

That part works, the bit I’m having trouble with is setting the new a value on page.

 

JSP…

<h:inputText

id="partNumber"

value="#{nonConformingMaterial.partNumber}"

required="true

      immediate="true"

      onchange="submit()"

>   

<f:valueChangeListener type="org.me.jsf.actions.NonConformingMaterialAL"/>

</h:inputText>

 

 

The code I have is…

 

CODE…

public class NonConformingMaterialAL implements ValueChangeListener {

 

public void processValueChange(ValueChangeEvent vce) throws AbortProcessingException  {

 

       String partNo = ((String)vce.getNewValue());

       System.out.println("A value has changed!" + partNo);

 

                  // This doesn’t save & show the new value.?!??!

       FacesContext ctxt =  FacesContext.getCurrentInstance();

       if (null != vce.getNewValue()) {

           ctxt.getExternalContext().getSessionMap().put(“SHOWTHIS”, “partNumber”);

                  }

 

      ctxt.renderResponse();

            }

}

 

This doesn’t set the value “SHOWTHIS” in the field though.

 

Can someone please help?

 

Thanks

Jeff.

Reply via email to