I'm writting an RCP application which has an application model that can be simplified as below:
==================================================
= lpart || rpart1 | rpart2 =
= -------------------- || ---------------------- =
= <a table> || <some sfuff about =
= || the selected item> =
==================================================
The window is divided into two part stacks: left and right
The left PS contains one part, and the part contains only a table
The right PS contains two parts, each will show some details about the selected item in the table
The problem:
It seems that Eclipse is lazily initializing my part implementation class. If I call MPart.getObject() on rpart2 before I ever clicked the tab, it returns null. Can I make Eclipse to initialize all my part implementation class when it starts up.
How can I tell which one of rpart1 and rpart2 is showing. I want to avoid loading data for both parts whenever the selection of the table changes, after all, only one of them is really showing.
What I want to achieve:
Whenever an item gets selected, both rpart1 and rpart2 get notified and remember the selection (item id or sth. similar). It will be impossible if rpart2 is lazily initialized.
Only the part that is currently showing will fetch the details it needs. It will be impossible if a part cannot tell whether it is showing.
When the other part gets selected, it will fetch and display its data according to the remembered selection. Well, this is the only part I know how to do it.
Any help would be really appreciated! Thanks a lot!
You can use the EPartService addPartListener method to add a listener that is notified about all part activation (and other) events.
I think EPartService.isPartVisible(MPart) (rather than MPart.isVisible()) solves your first problem.
Related
I have two JSF pages search.jsf and details.jsf . In the search.jsf I have an ADF search form. I just drag and drop the View Criteria as ADF Query Panel with Table. The result of user search will be shown in an ADF table. One of the column is a link that will direct the user to the details.jsf to show the details of the selected row.
Every things works fine for the first time in the search.jsf . Problem is when the user go back from details.jsf to search.jsf , The Search form is not working and only showing the previous selected row and after pressing default search button multiple times this error message is coming:
Definition name 1 of type Attribute is invalid.
I search in the internet. Some have similar problem says that there is problem in the attributes naming. I Checked nothing wrong, I even create new view object and still facing the same error. Also, I checked the page definition, DataBindings and DataControl files, no problems there.
I am using Jdeveloper 11.1.2.3 with ADF Technology
That error generally indicates that there was a change in your View Objects attributes (query, names etc). Try creating a new search page, and see if it works. If it is OK, try to figure out what has been changed or in the worst case re-implement the searchPage. Take a look even in the VO used in "details.jsf" just to be sure. Tung
I'm facing problem with a selectOneChoice inside a TreeTable in clickToEdit mode.
When scrolling down and returning up, the value of the combo of the focused row is cleaned.
To replicate the issue, just navigate to the ADF demo :
clickToEditTreeTable
Expand all
Select the first row
Change the value of the Col2 to HeadPhone
With the focus still on first row, scroll down until the Fetching Data message appear
Scroll up back to the first row
The value of the Col2 is changed to Mouse
How can i avoid this ?
In my application i have noticed that the value change listener is fired the first time when changing the value, and a second time while scrolling the treeTable,setting it to null
This problem occurs ONLY with a treeTable in editingMode clickToEdit.
The standard table works fine.
My jdev is 11.1.2.1.0.
Thx in advance.
Since you are able to reproduce this issue in ADF demo itself its either an ADF bug or limitation.
I think thats a kind of a bug. You can try to file service request on it.
It seems that since you don't commit your changes (because you still stays on this row). On another fetch your changes ain't being saved and on refetch you getting old values.
As for workaround for this issue:
If your tree ain't too large, you can set iterator RangeSize to -1 to fetch all rows at once to avoid more rows fetching. However if you have a lot of rows, you'll have a perfomance issues.
You can try to set autosubmit property on this field to true, so it will save your data (and hopefully load) on comback (even if it don't, you can do it in your bean). May be you will also need to put there clientListener to submit data, when your control loses focus.
Don't use clickToEdit for this control or call it a feature (no submit - no changes) :)
Since i can't wait a fix, i have found a workaround to the problem.
The value is setted to null ( or false for the checkboxes ), when the element is renderized the second time on scrolling back, because the setter property of the bean and ( if present ) the value change of the selectOneChoice are invoked.
So i have setted a clientListener on the valueChange event that unlike the valueChangeListener is fired correctly, and a fake property as value.
I'm new to GWT. I have a simple SuggestBox which is populated using a MultiWordSuggestOracle. Users input their data to this SuggestBox, and if they find any match with the existing Suggestions its well and good. I'm able to retrieve this value in the SelectionHandler code as below.
display.getSuggestBox().addSelectionHandler(new SelectionHandler<Suggestion>() {
public void onSelection(SelectionEvent<Suggestion> event) {
String selectedProperty = ((SuggestBox)event.getSource()).getValue();
// do something with the property value
}
});
But users are allowed to enter values which are not already in the Suggestion oracle, in which case I should read this value and do something with this,may be saving to db as a new data.(The thing which I'm looking for is something like a browsers navigation widget where we show suggestions, users can pick up any suggestion or he can type in his new entry and carry on.) What I needed is a way to retrieve this new text user has entered? Data will be read on a button click. What I tried out is this.
display.getSaveBtn().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String selectedProperty = display.getSuggestBox().getValue();
//String selectedProperty2 = display.getSuggestBox().getText();
// Blank in both cases :(
// tried display.getSuggestBox().getTextBox().getValue(),but blank again
}
});
I tried to employ onChange() event handlers (as shown below)
display.getSuggestBox().addValueChangeHandler(new ValueChangeHandler<String>() {
public void onValueChange(ValueChangeEvent<String> event) {
String selectedProperty = ((SuggestBox)event.getSource()).getValue();
Window.alert("on change -- "+selectedProperty);
}
});
This is working fine except one scenario. Suppose there are two suggestions in the oracle,say 'createTicketWsdl' and 'createTicketTimeout'. When the user types in 'cr', he is opted with these two options, and if he selects 'createTicketWsdl' by pressing keyboard ENTER, then my alert is printing 'createTicketWsdl' which is correct. But if he selects 'createTicketWsdl' using mouse, then my alert is printing 'cr' (I tried to post the screenshot to give a better understanding, but being a new user I'm not allowed).(which I wanted to get as 'createTicketWsdl'since thats what he has selected). Soon after printing my alert, the value in the SuggestBox changes to 'createTicketWsdl'.
Is there a way to retrieve the value of the suggest box? I saw a similiar thread GWT SuggestBox + ListBox Widget, where some source code for a custom widget is available. But I didn't take the pain of trying out that, since what I want is simply get the current value from the SuggestBox and I hope there should be some easy way.
Thanks for all your help!
Your question is not very clear. You need to clarify your language a lil' bit. For example - is the following a question or an assertion? I mean, it sounds like an assertion but it has a question mark.
What I needed is a way to retrieve this new text user has entered?
Also, I do not understand what you mean by "he is opted by". Did you mean to say, "he is presented with the options ..." ?
Therefore, I am guessing your situation.
You have a listbox of existing items.
You have a textbox which allows freeform text entry
Any items whose prefix values matches the current textbox entry, the listbox items would be filtered to be limited to the matching items.
Even if the current textbox entry presents matching prefixes to filtering the listbox, the user can still perform freeform text entry. So, there are two possible cases here
4.1 the user clicks on the list box to select one of the filtered items
4.2 the user press enter key, which triggers selection of the current value of the textbox.
However, you find your widget participating in a race condition, so that when you click on the widget, the ValueChangeHandler gets triggered rather than the SelectionHandler. I do not know the structure of your widget so that is my best guess.
The problem is that you are allowing two separate modes of obtaining an outcome and you probably did not have well-defined state machine to handle choosing the appropriate mode. One mode is by the textbox and the other is by selection on the listbox - and you do not have a well-defined way of which would mode would be effective at any moment.
If my guess is accurate, this is what you need to do:
You must restrict your outcome to coming from only the textbox.
Your listbox selection must not trigger any outcome. Any change in listbox selection must propagate back to the textbox - to allow the user the chance of making further freeform entry based on that value.
only the keyboard enter on the textbox will trigger the final outcome.
I am writing a Java application for digitizing a group of documents in the office that I am working in and I am wanting to check if 5 textfields are populated and 4 combobox fields as well before the save button is enabled (I have it checking if i press a button (that happily says "Check"), but i would much rather have it auto-check to see if they are populated or if they are null).
If it makes a difference i am using NetBeans for this project.
Basically I need the fields to have something in them before the document can be saved.
Any and all help will be greatly appreciated as this is the final step in creating this application... :D
Thanks,
Erik
There are two ways (I can think of):
1- Put a listener on each field, this listener will be triggered when the field is populated. Inside the listener increment a counter for example, or set a flag. If all flags are set or if the counter reaches (9 in your example) then enable the button.
2- Enable the Save button, but call a validate() method before doing the Save action. Any unpopulated field will have a red mark beside it (shown by validating) like in web applications.
In my application, I have URN-identified data coming in from the server. I'm in the process of abstracting as far as possible so there is very little to no logical code in my views, and I'm using a generic presenter that wraps those views. All widgets have URNs, making it super easy to map incoming data to a specific widget (until now, a 1 to 1 relationship). This has worked well for pretty much every widget, and now I've reached a point where I'm tripped up.
Assume I have (just for simplicity's sake) two RadioButton elements on a view. These buttons belong to a "group" (just by setting their name values to the same thing), but obviously they're 2 distinct elements. I can't map my URN-identified data to a single widget as in every other case because, in this case, it is two widgets.
Here's an example of what I mean:
Utility Company is a ListBox, so just one widget there. I map each item in the list to a specific Enum value.
Utility Rate is a TextBox, so again just one widget to map.
For Energy Usage, they can select to use either an average for the year or input 12 monthly values. I'm stuck here. I can't map to just one of the RadioButton elements, because then I'd need some extra logic in the view to handle the behavior appropriately.
Am I stuck mapping to just one widget and sticking (unwanted) logic in my view to determine what the state of all of the elements should be based on the value that came in for the one widget that is mapped?
How should I handle this case?
Edit (Solution):
Following the concepts of jusio's answer, I came up with a workable solution. Because I didn't want to go sticking special case handling through my logic to take care of a non-widget, I created a RadioButtonSet faux widget (public class RadioButtonSet <T extends Enum<?> & HasDisplayText> extends Widget implements HasValueChangeHandlers<T>, HasValue<T>), into which I manually pass the radios I intend to group. Having done that, I can get or set its value and have it fire appropriate events when the user changes the selection. Then mapping the collection of radios is no different than doing so for a listbox. Thanks jusio.
I believe in your case you shouldn't treat radio buttons as two separate widgets, basically in your case you can treat the radio button group as combo box, because behavior is almost the same (the only problem is that you have additional master detail). So basically what you will have to do is to wrap real BO objects into some kind of RadioButtonGroupModel, and give it to view, view can take this model and generate radio buttons (with some editors or whatever else). I remember running into this problem when i was extending databinding FW for JFace, and this was the best way I could find to solve this problem.
If I understood correctly the problem, there are 2 possible solutions:
Give each RadioButton a unique URN (ex: oldURN_1 , oldURN_2)
When you send data for a URN, disable the other one
Keep the same Name for each RadioButton but add a number variable in the data the server sends indicating which radioButton it is supposed to use (ex: 0 for Average and 1 for Monthly)