noSuchElementException on form submit - java

We're using JSF 1.2 for our application. There is a selectBooleanCheckbox on on of the screens that represents a field in the backing bean. When loading the JSP, the value is shown correctly. There are three command buttons on the page; one calls a save function in the backing bean and then navigates to another screen. The other two are used to call utility methods in the backing bean before refreshing the screen. If the checkbox is unchecked, all three buttons function correctly. If the checkbox is checked, only the first functions as intended.
When the checkbox is selected, the backing bean is initialized but before the methods are called, a noSuchElementException is thrown from the generated servlet. The exception has a null message and no stack trace, so it's not incredibly helpful.
I've verified that the values of each field remain consistent with those that the screen is originally populated with. Dropdown inconsistencies are the only times I've ever seen this before, so any pointers on what else to check would be greatly appreciated. Unfortunately, I'm unable to post the code here but I will answer any questions if I am able.

Take a closer look at your buttons , and how is the working one being different from the non working ones.

Related

Wicket Page's ListView LoadableDetachableModel is modified via AJAX call. Page doesn't re-draw

Consider a page which sub-classes WebPage. Its constructor creates
and adds a WebMarkupContainer, which contains a ListView component
backed by a LoadableDetachableModel.
The page also adds two instances of anonymous sub-classes of AbstractDefaultAjaxBehavior [each overriding the class' renderHead and respond methods].
The corresponding HTML contains a <div> bound by wicket:id to the WMC
and a <table> with <tr>'s bound to the ListView component's ListItems.
The page displays correctly the first time.
Based on user interaction with the client, the AbstractDefaultAjaxBehavior in question sets information on the model's model object. The information is intended to be used to change the way a specific listitem appears as a <td> within the row in the table -- specifically a selected row's text should appear in bold face.
Diagnostic debugger breakpoints and System.out info on both sides of
the AJAX call confirm that the behavior's respond method is being called correctly and that the model object is being correctly modified.
The page is never re-drawn automatically. Manually re-loading the page
from the browser demonstrates correct behavior.
I've researched this problem and found a variety of possibly related
solutions, which I've tried, including
calling target.add( webMarkupContainer); from the behavior's
respond method, in conjunction with
calling target.appendJavaScript( "window.location.reload();" ); from the respond method.
calling setResponsePage( this );, setResponsePage( Page.class );, and setResponsePage( getPage() ); from the respond method, as well as from an overridden onBeforeRender method on the page.
Any suggestions?
AbstractDefaultAjaxBehavior does not update any components automatically.
Did target.add( webMarkupContainer) help? If not, have you called webMarkupContainer.setOutputMarkupId(true)?

Is the AccessibleContext really a Java Object reference?

I am able to use WindowsAccessBridge.dll to get access to java window (SwingSet2), and use the dll methods to interact with the controls.
I can iterate the tree (of java controls) using code shown here, and get information from the controls,
and I can do actions like SetText in Text box, or send click action to a button etc.
However, I am finding that the accessibility contexts are not consistent:
The SetText method works perfectly when I use the accessibility context got from the 'setMousePressedFP' method of the dll, after clicking on the text box.
However, I cant use the accessibility context got by iterating the control tree when trying to set text in a text box, although I verified that the other information e.g. size and other properties of the text box is same.
From this doc:
"The functions GetAccessibleContextAt and
GetAccessibleContextWithFocus retrieve an AccessibleContext object,
which is a magic cookie (really a Java Object reference) to an
Accessible object and a JVM cookie. "
However, the accessibility context differs everytime I click on the text box (without restarting the java program). The vmID matches eveytime.
If the AccessibleContext is really a Java Object reference, shouldnt I get the same AccessibleContext number everytime I click on the same control (without restarting the java window) ? and shouldnt that AccessibleContext number also be available in the tree?
Worst part is that the settext method doesnt work when I use the AccessibleContext got from iterating the control tree.
Edit to clarify the question further:
I am clicking on the same text box, so I would expect the windowsaccessdll function to return reference to the same control. As a long value the accessibeContext is different everytime I click, but its ok as the SetText method works everytime with the different long values and I can see the new text set in the text box.
The problem is when I iterate the control tree and the accessibility context got from the tree iteration doesnt work for the SetText method.
More specifically - how does the AccessibleContext compare to a c pointer - the c pointer would always be same when I get it for a specific control. The AccessibleContext appears to be a 8 digit long value that is different by few tens or hundreds based on where the mouse is clicked inside the text box.
Thanks in Advance.

ADF Web Application: how to add and modify UI components on page loading (before it's displayed)?

I would like to know which are the different available approaches to add, modify and delete UI components before a page loaded.
A practical example that I should handle is the following:
In my ADF Fusion Web Application (developed with JDev12.1.3) there are the pages login.jspx and main.jspx: if the user logs in correctly navigation to main.jspx happens.
In main.jspx there is an empty menu bar that at runtime I would like to fill with menus and menu items when the page loads, in function of the logged in user.
In the same page, in function of the logged in user, I also would like to add at runtime some UI components (output texts, buttons, ...) whith the chance to set their properties.
Could you kindly advice me which approaches I can follow to accomplish these duties?
Thanks,
Federico
Why not using the rendered attribute? Based on the condition the components will be rendered or not.
Personally the two approaches i've used on my works where:
1. Using the beforePhaseListener on the f:view component. Example: Before Phase on JSF page. But it might cause you some problems when taking account of adf lifecycle, especially if you have integrated parts (or even some simple jQuery components...).
2. And i think this would just do fine in your case, use a f:event component of type "preRenderComponent". Example: How to use prerendercomponent. I suggest this second option
Note: It's true that these aren't ADF Faces components, but since it's built on top of JSF, they work as they should. I can assure you they do work on 11g and don't expect any problems on 12c.
I see two approaches. Use addChild() and related methods to physically add/remove menu items, or have the menu pre-built and use the visible property to show hide items.
As far as making this happen in custom code, you can use a Backing Bean (Managed Bean) that contains the code to determine what items to add/remove or make visible based on whatever criteria you choose. To call this code, you can 1) use the Invoke action in the rebinding layer - have it call the desired backing bean method - make sure to drag the Invoke action the TOP of the executables list. This is the older, less preferred method. The newer, more preferred method is to add the backing bean method to the Task flow and have it navigate to the deserted page. This method can be part of the navigation form another page. Ex: After successful Login, navigate to your method an chav sit navigate to the Main page. The method will execute before the page loads and will set values to have the items added or visible or not.
RichSelectOneChoice choiceList;
List child = choiceList.getChildren();
child.clear();
for (int i = 0; i < child.size(); i++){
child.remove(i);
}
if ("1..1".equalsIgnoreCase(ccCode)){
UISelectItem addChild = new UISelectItem();
addChild.setItemLabel("1..1");
addChild.setItemValue("1..1");
child.add(addChild);
} else if ("0..1".equalsIgnoreCase(ccCode)){
UISelectItem addChild1 = new UISelectItem();
addChild1.setItemLabel("0..1");
addChild1.setItemValue("0..1");
child.add(addChild1);
UISelectItem addChild2 = new UISelectItem();
addChild2.setItemLabel("1..1");
addChild2.setItemValue("1..1");
child.add(addChild2);
}
Have you posted this question to he ADF forum, here?

How to modify a JSF backing bean value before the UpdateModelValuesPhase?

I have a JSF form that consists of a grid and some detail fields. The detail fields contain the data of the first row in the grid. I have a backing bean that listens to the grid row selection and updates the detail fields' backing beans to represent the new values. Here comes the problem: I update the detail fields as needed (the listener is invoked in the ApplyRequestValuesPhase), but later the JSF framework reassings the old values to them in the UpdateModelValuesPhase.
My question is how to fix it? How could I assign new values to some JSF components from the grid selection change event?
Note: this is about the very the same thing as in JSF component doesn't update if changes came from grid click but I see the problem more clearly now I think, that's why I posted a new question.
It's not normal that a listener is invoked during apply request values phase. Perhaps you've set immediate="true" somewhere which will cause the actions to be performed during apply request values phase. You need to make sure that the listener is invoked during the invoke action phase which runs right after the update model values phase. Set immediate="false" or just remove the attribute altogether, it's the default behaviour already.
As per the comments, you seem to indeed have set the immediate="true" on the row selector, you'd need to remove it.

JSF component doesn't update if changes came from grid click

I have a JSF/IceFaces application where there is a screen divided into 3 sections. Search fields, a grid and some details fields below. Currently if I enter some data into the search fields and click on a Search button (!) the grid shows the results and a certain method is called that puts the first result record's details into the backing beans of the details fields below the grid. This shows that there is no problem with the way I put data into the details fields.
However I have a gridclicklistener method as well that would like to change the detail fields according to the selection. After the click the same method gets called with the correct parameters that works well if invoked after the click on the Search button. The data is updated in the backing beans but the changes are not rendered even if I click the refresh button in the browser.
I found that if I click on the search button, the data-updating-method gets called from InvokeApplicationPhase.execute. When I get to this line after the grid click then it is from the ApplyRequestValuesPhase.
Do you have any ideas what could make this difference and how to get this work?
Update:
I can clearly see the updated value in the backing bean but it is not reflected on screen at all, even after F5.
I don't know what is causing your original problem.
With the icefaces push renderer however you could force an update:
http://wiki.icefaces.org/display/ICE/Getting+Started+with+ICEfaces+2#GettingStartedwithICEfaces2-icepush

Categories

Resources