tabbedPane selectionChangeListener not invoking method on tab selection - openfaces

I am having some problems getting the method specified in selectionChangeListener invoked on tab change.
The loadingMode is default, ajaxLazy, which means it should be called the first time a tab is selected. The tabbedPane is wrapped in
The el expression looks like:
selectionChangeListener="#{pageController.tabSelected}"
The method signature of the method binding is:
#Component("pageController") // Using spring for bean management
#Scope("request)"
public class PageController {
public void tabSelected(SelectionChangeEvent e)
}
It is not throwing any exceptions so it is not even trying to resolve the method binding.
Any ideas?

Try this:
<o:tabbedPane loadingMode="server" rendered="true" selectionChangeListener="#{yourBeanName.listenerMethod}">
...
</o:tabbedPane>
As you can see I`m using server as loading mode. That way the listener method will be invoked each time a tab is clicked. If you use client as loading mode, the tab click event will not be picked up by the server.
For more info you can view the documentation for tabbedPane

Related

Passing arguments to a window in ExtJs 6?

I would like to a pass a record from a grid to a window that I create,
Ext.create('MyWindow',
{recordRef: record}).show();
where record is an argument that is passed into my rowdblclick function but when I try to access recordRef (like below) during debugging, it is undefined.
var me = this;
var record = me.getView().recordRef;
The code fragment above is in a controller for MyWindow.js
The reason this is happening is probably because you are using an event to access recordRef that is called before the constructor assigns recordRef to your window as a property.
My advice would be to use the show event just to be sure, here is a fiddle: https://fiddle.sencha.com/#view/editor&fiddle/232m
You can access custom configs you add to a component with getConfig - in this case it would be this.getConfig('recordRef')
Here's a small fiddle where the custom config is logged to the console, and set to be the window's title.

adf declarative component custom methods queueEvent() not working

I am using Oracle ADF JDev 12.1.3
I have a custom declarative LOV component and one custom method "valueChangeEvent",
after user select some values from the popup, i will do some validations, if all validations are ok, then I need to raise "valueChangeEvent" event,
so that in the final jspx page additional logic's can be implemented,
My declarative component method definition as follows
<method-attribute>
<attribute-name>
valueChangeListener
</attribute-name>
<method-signature>
java.lang.Void method(javax.faces.event.ValueChangeEvent)
</method-signature>
<required>
false
</required>
</method-attribute>
In my custom LOV Component, i have one input text and button, I tried the following to invoke my custom method within the command button action, but it does not invoke the event at the main form, but no error shows
// get the component reference using Face Context ValueExpression
_this = getThisDeclarativeCompoent();
//try to queue the valueChangeEvent - but this does not work
_this.queueEvent(new ValueChangeEvent(_this, NewValue, OldValue));
Consuming application code is as follows
<af:declarativeComponent viewId="/ASGLOVBrowser.jspx" id="dc3" label="Modules" LOV_Name="MODULE"
bindingAttribute="#{bindings.ModuleId}" showDescription="true"
multiSelect="false" matchingField="CODE"
valueChangeListener="#{viewScope.DeclarativeTestBean.test_valueChangeEvent}"/>
appreciate if someone can help...
Value Change event is raised by the framework only, when input value changes, therefore you can't initiate the event without the value being changed either from UI or programatically.
So, you can get a reference of the input text UIComponent and change the value programatically:
RichInputText uiComp = <<<get reference>>>;
uiComp.setValue(newValue);

How to handle Element is no longer attached to the DOM in page object?

I'm trying to test the web site using Page Object, When I'm executing my scripts, I'm getting Element is no longer attached to the DOM (Selenium::WebDriver::Error::StaleElementReferenceError) error message intermittently while calling a function.
How can I overcome from this issue, If any suggestions?
We also faced the same problem in our project. One way of overcoming this is to use a try catch block within the method which is causing this problem. Inside the catch block again re execute the same lines of code/another method. This will take care of the issue.
You get this exception when the element you are interacting with has been changed in the DOM. If you capturing the element in the WebElement object and then using that object further to perform some clicks/typing and if in between the reference to that element changed, then the object you are using will no longer refer to a correct locator. Try using the element locators at the time of interacting with the element instead of capturing it in a WebElement object first and then using that object further.
E.g. instead of doing :
WebElement e = driver.findElement(By.id("someID"));
e.click();
.
.
.
e.click();
try to use :
driver.findElement(by.id("someID")).click();
.
.
.
driver.findElement(by.id("someID")).click();
Otherwise, you can use Vinay's method.
Use PageFactory to initialize your page objects.
It will create lazy proxies to the actual element.
public class PageObject {
#FindBy(id="someID")
private WebElement someElement;
public void doSomething() {
someElement.click();
}
}
PageObject po = PageFactory.initElements(driver, PageObject.class);
If you do not use #CacheLookup along with #FindBy, any time you use someElement, it will go and look for this element using the finder.

Forcing Object Data Source To Reinstantiate

I am using the XPages Mobile Controls with an Object data source (Java Class which is NOT a managed bean) tied to View scope on a second app page. I have resetContent on the second page set to true. So I would have assumed the Object Data Source would be destroyed and recreated every time I transitioned to the second page.
When I transition to the second page the first time, the createObject() method is invoked as expected. If I transition to the second page using a button AND set forceFullRefresh to true the createObject() method is invoked. If, however I have a Rounded List Item with a moveTo specified for the second page the createObject() method does not get invoked. Instead the object remains set to the last value it was using when that application page was last accessed.
Is there a way to force the createObject() method to be invoked every time I transition to the page?
Another way is to call the refresh method of the datasource in SSJS.
Assumning you have only one datasource on the page, you can access the ObjectDataSource from the view:
var ods:com.ibm.xsp.extlib.model.ObjectDataSource = view.getData().get(0);
ods.refresh()
This executes the createObject method binding and reinstantiate the datasource.
The solution turned out to be to move the object data source from view scope to request scope. This is possible because I do not have the need for any partial refreshes on that page until the details are ready to be submitted.

Show custom pop up warning message when user changes any value (text box/LOV) on page

I have requirement to show custom pop up warning message when user changes any value (text box/LOV) on page and close tab/cancel button by mistake.
Option I tried are:
a) Within application we are using a complex task flow/RegionModel for 7 different scenario's. Also requirement is to display custom message - Hence could not use approach "unsaveddatawarning"
http://www.oracle.com/technetwork/developer-tools/adf/unsaveddatawarning-100139.html
b) Second option I tried was to have custom region controller:
CustomRegionController implements RegionController
Inside validateRegion(RegionContext regionContext) thought to find if page data is dirty
AdfFacesContext.getCurrentInstance().getDirtyPageHandler().isDataDirty();
or
DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCDataControl cDataControl = dcBindings.getDataControl();
boolean dirtyFlag = cDataControl.isTransactionModified();
In both scenario it always gives true (seems due to common set of VO/View Link application module always gets dirty when data is being rendered on page load).
Last option I am left with is to invoke valueChangeListener for each element (textbaox, LOV, Check box). I do not like this option at all. Please suggest if there can be better way to handle this scenario.
Why is using a value change listener a problem? Have each input component call the same VCL method in the backing bean. If necessary you can get the component id from the vcl event object.

Resources