Easiest way to get the current binding from the bean


use the following snippet to get the current binding

BindingContainer bindings =  BindingContext.getCurrent().getCurrentBindingsEntry();
 AttributeBinding at = (AttributeBinding)bindings.getControlBinding("Period");
 at.getInputValue();

The above mentioned code is useful only in case of retrieving values of any attribute binding in the page definition file. To retrieve specific information use it like

//For search binding use it like
FacesCtrlSearchBinding fc =
(FacesCtrlSearchBinding)bindings.findExecutableBinding("PeriodQuery");
or
FacesCtrlSearchBinding fc =
(FacesCtrlSearchBinding)bindings.get("PeriodQuery");

//For LOV binding use it like
FacesCtrlLOVBinding fc = (FacesCtrlLOVBinding)bindings.get("PeriodLOV");

some of the useful methods that can also be used for retrieving binding is

private BindingContainer getBindings() {
BindingContainer bindings =
(BindingContainer)fc.getApplication().evaluateExpressionGet(fc, "#{bindings}",
 BindingContainer.class);
return (bindings == null) ? null : bindings;
 }

to retrieve the bindings  or executable you use it like

//to retireve the tree/table bindings
FacesCtrlHierBinding fc = (FacesCtrlHierBinding)bindings.get("Period");

//to retireve the tree/table iterator
DCIteratorBinding dc = (DCIteratorBinding)bindings.get("PeriodIterator");
Advertisements

6 thoughts on “Easiest way to get the current binding from the bean

      1. vtkrishn Post author

        yes that is always going to be returning a binding but its better to have a check as part of good coding standard.

  1. Ilya

    Hi Andrejus,I get the same error but my case is a lot different.I ceertad a simple(No Security enabled) jspx page in JDeveloper 11g and it works really perfect on pc browsers.I get that error whenever I want to load that page on my mobile emulator browser!!! It doesn’t work even on real mobile browsers like iphone Safari.Any suggestions?Thanks,Shahab

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s