X

Shay Shmeltzer's Oracle Development Tools Tips

  • June 22, 2009

Setting parameter value for binding with code

Shay Shmeltzer
Director of Product Management - Oracle

Back in the 10.1.3 days I wrote an entry that showed how to set the value of a parameter that is referenced in your page's binding by writing some code in your backing bean.

Well with 11g we moved to JSF 1.2 and things have changed a bit.

And today I needed to look up the update syntax for a demo I was working on.

Since this is a useful little piece of code I'm pasting it here for my own future reference.

A special shout out to Edwin Biemond for this post that has a lot of other useful code bits.

If you want more of these download the Fusion Order demo and look up the JSFUtil java class that is used throughout the demo when coding in the backing bean is needed.

[code]

FacesContext facesCtx = FacesContext.getCurrentInstance();

Application app = facesCtx.getApplication();

ExpressionFactory elFactory = app.getExpressionFactory();

ELContext elContext = facesCtx.getELContext();

ValueExpression ve =

elFactory.createValueExpression(elContext, "#{bindings.p_zip.inputValue}",

Object.class);

ve.setValue(elContext, newValue);

[/code]

Join the discussion

Comments ( 4 )
  • Darren Thursday, September 1, 2011

    Hi Shay,

    This really doesn't work for me - and I've now tried both the old way and the new way (with 11g). My web service request works, but I have to forcibly type the word "true" into an input box or my call simply doesn't contain the 'main="true"' component in my web service SOAP request which is essential for the service to respond with success.

    I've even tried hard-coding the value of the text-box to true and that still doesn't give me the required functionality and I can't expect my users to randomly enter 'true' in a text box just to use a web service. Would it help if I sent a video to describe my problem?

    Any help gratefully appreciated.

    Many thanks,

    Darren


  • Shay Thursday, September 1, 2011

    Darren, I would suggest that you try and debug your code as it runs and see where it fails.

    Also - have a look at your binding tab for the page and locate the parameter - if you just need it to be "true" then you can hard code the value for the parameter in the binding tab.


  • Michael Monday, July 24, 2017
    I have been using Jdev for more than 10 years and this Faces is hard to follow. This little bit od code really helped. I want to really learn this material better. Do you have any suggestions as to where I may go for a solid read and tutorial? Thanks
  • Shay Monday, July 24, 2017
    Michael, I would highly recommend watching some of the ADF training we recorded for the "ADF Insider Advanced" series.
    Specifically the one about binding for topics like the above.http://www.oracle.com/technetwork/topics/adfinsider-093342.html
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.