Can I have multiple feedback panels and determine somehow which one belongs to what?
When I tried to add more than one, all validation messages go to all panels.
You could use an IFeedbackMessageFilter as you found out by yourself. As for the negated filter mentioned in your answer, I suppose you want to catch any previously undisplayed message in a final FeedbackPanel. This can be archived using a FeedbackMassagefilter with the following accept method:
public boolean accept(FeedbackMessage message) {
return !message.isRendered();
}
Found the answer. It's possible to filter the messages going to the feedbackpanel using IFeedbackMessageFilter:
this.feedbackPanel.setFilter( new ContainerFeedbackMessageFilter(this) );
Still, I need some kind of negating filter for the other one.
Related
I'm new at Apache Isis and I'm stuck.
I want to create my own submit form with editable parameters for search some entities and a grid with search results below.
Firstly, I created #DomainObject(nature=Nature.VIEW_MODEL) with search results collection, parameters for search and #Action for search.
After deeper research, I found out strict implementations for actions (For exapmle ActionParametersFormPanel). Can I use #Action and edit #DomainObject properties(my search parameters for action) without prompts?
Can I implement it by layout.xml?
Then I tried to change a component as described here: 6.2 Replacing page elements, but I was confused which ComponentType and IModel should I use, maybe ComponentType.PARAMETERS and ActionModel or implement my own IModel for my case.
Should I implement my own Wicket page for search and register it by PageClassList interface, as described here: 6.3 Custom pages
As I understood I need to replace page class for one of PageType, but which one should I change?
So, the question is how to implement such issues properly? Which way should I choose?
Thank you!
===================== UPDATE ===================
I've implemented HomePageViewModel in this way:
#DomainObject(
nature = Nature.VIEW_MODEL,
objectType = "homepage.HomePageViewModel"
)
#Setter #Getter
public class HomePageViewModel {
private String id;
private String type;
public TranslatableString title() {
return TranslatableString.tr("My custom search");
}
public List<SimpleObject> getObjects() {
return simpleObjectRepository.listAll();
}
#Action
public HomePageViewModel search(
#ParameterLayout(named = "Id")
String id,
#ParameterLayout(named = "Type")
String type
){
setId(id);
setType(type);
// finding objects by entered parameters is not implemented yet
return this;
}
#javax.inject.Inject
SimpleObjectRepository simpleObjectRepository;
}
And it works in this way:
I want to implement a built-in-ViewModel action with parameters without any dialog windows, smth like this:
1) Is it possible to create smth like ActionParametersFormPanel based on ComponentType.PARAMETERS and ActionModel and use this component as #Action in my ViewModel?
2) Or I should use, as you said, ComponentType.COLLECTION_CONTENTS? As I inderstand my search result grid and my search input panel will be like ONE my stub component?
Thank you.
We have a JIRA ticket in our JIRA to implement a filterable/searchable component, but it hasn't yet made it to the top of the list for implementation.
As an alternative, you could have a view model that provides the parameters you want to filter on as properties, with a table underneath. (I see you asked another question here on SO re properties on view models, so perhaps you are moving in that direction also... I've answered that question).
If you do want to have a stab at implementing that ticket, then the ComponentTYpe to use is COLLECTION_CONTENTS. If you take a look at the isisaddons, eg for excel or gmap3 then it might help get you started.
======= UPDATE TO ANSWER (based on update made to query) ==========
I have some good news for you. v1.15.0-SNAPSHOT, which should be released in the couple of weeks, has support for "inline prompts". You should find these give a user experience very similar to what you are after, with no further work needed on your part.
To try it out, check out the current trunk, and then load the simpleapp (in examples/application/simpleapp). You should see that editing properties and invoking actions uses the new inline prompt style.
HTH
Dan
I spent many hours to search this info "How to make SuggestBox to reliably RPC-call to Server DB in GWTP (Gwt platform) Framework" but couldn't find any answer about it.
In fact, there were some answers but they were for people who do not use GWTP. For example, i found a website (http://jagadesh4java.blogspot.com.au/2009/03/hi-every-one-this-is-my-first-blog.html) that guide to code SuggestBox & RPC & it suggests these classes:
-Client Side:
+ interface SuggestService extends RemoteService
+ interface SuggestServiceAsync
+ class Suggestions implements IsSerializable, Suggestion
+ class SuggestionOracle extends SuggestOracle
-Server Side:
+ class SuggestServiceImpl extends RemoteServiceServlet implements
SuggestService
I tried to follow up that website but i got error:
[WARN] failed SelectChannelConnector#127.0.0.1:8888
java.net.BindException: Address already in use: bind..........
The above guide clearly was not for people who use GWTP.
My task is I have a dictionary that contains 200k of English words & I want to have a suggest box that when user types any char or word it will look up into DB & suggest accordingly. Ex, when user types "c" it will suggest "cat, car, cut, etc", when typing "car" it will suggest "car service", "carbon", etc.
So I come up with my own solution, even it works but I am feeling I am not doing right thing. My solution is quite simple that I just bring the data from DB down & add them into MultiWordSuggestOracle. Whenever it found a list of word in DB, it won't clear the old data but just keep adding the new list into MultiWordSuggestOracle. However, my program will not constantly call to DB everytime user types a char, but it will call to DB only if the wordInTheMultiWordSuggestOracleList.indexOf(suggestBox.getText(),0)>0. However, there is no way to loop each string in the MultiWordSuggestOracle, so I used List<String> accumulatedSuggestedWordsList=new ArrayList<String>() to store data. Pls see ex:
private final MultiWordSuggestOracle mySuggestions = new MultiWordSuggestOracle();
private List<String> accumulatedSuggestedWordsList=new ArrayList<String>();
private void updateSuggestions(List<String> suggestedWordsList) {
// call some service to load the suggestions
for(int i=0;i<suggestedWordsList.size(); i++){
mySuggestions.add(suggestedWordsList.get(i));
accumulatedSuggestedWordsList.add(suggestedWordsList.get(i));
}
}
#Override
protected void onBind() {
super.onBind();
final SuggestBox suggestBox = new SuggestBox(mySuggestions);
getView().getShowingTriplePanel().add(suggestBox);
suggestBox.addKeyDownHandler(new KeyDownHandler(){
#Override
public void onKeyDown(KeyDownEvent event) {
// TODO Auto-generated method stub
String word=suggestBox.getText();
int index=-1;
for(int i=0; i<accumulatedSuggestedWordsList.size();i++){
String w=accumulatedSuggestedWordsList.get(i);
index=w.indexOf(word,0);
if(index>0)
break;
}
if(index==0 || index==-1){
GetWordFromDictionary action=new tWordFromDictionary(suggestBox.getText());
action.setActionType("getSuggestedWords");
dispatchAsync.execute(action, getWordFromDictionaryCallback);
}
}
});
}
private AsyncCallback<GetWordFromDictionaryResult> getWordFromDictionaryCallback=new AsyncCallback<GetWordFromDictionaryResult>(){
#Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
#Override
public void onSuccess(GetWordFromDictionaryResult result) {
// TODO Auto-generated method stub
List<String> suggestedWordsFromDictionaryList=result.getSuggestedWordsFromDictionaryList();
updateSuggestions(suggestedWordsFromDictionaryList);
}
};
The Result: it works but the suggest only show up if i type the "Backspace" button. For ex, when i type the word "car" then no suggested list popup, it only popup "car service, car sale, etc" when i hit the backspace button.
So, can u evaluate my solution? I am feeling i am not doing right. If i am not doing right thing, can u provide a SuggestBox PRC for GWTPframework?
Very Important Note:
How to build a Reliable SuggestBox PRC that prevents the a denial of service attack on our own servers?
What if there are too many calls generated by many people rapidly typing in a suggest box?
Actually I just found an error:
SQL Exception: Data source rejected establishment of connection, message from server: "Too many connections" --> so there must be something wrong with my solution
I knew why i got "Too many connections" error. For example, when i type "ambassador" into the suggest box, & i saw my server call the Db 9 times continuously.
-1st call, it will search any word like 'a%'
-2nd call, it will search any word like 'am%'
-3nd call, it will search any word like 'amb%'
The first problem is that it create too many calls at 1 time, second it is not effective cos the first time call like 'a%' may already contains word that will be called at 2nd time like 'am%', so it duplicate the data. Question is how to code to avoid this ineffectiveness.
Someone suggests to use RPCSuggestOracle.java (https://code.google.com/p/google-web-toolkit-incubator/source/browse/trunk/src/com/google/gwt/widgetideas/client/RPCSuggestOracle.java?spec=svn1310&r=1310)
If you can provide an example of using RPCSuggestOracle.java, that will be great.
I hope your answer will help a lot of other people.
There were an old inspiring blog post, from the Lombardi Development, that I remember addresses almost all questions you are looking for. It took me a while to find that out but, fortunately, it has simply been moved! And the sources are available. Have a look.
Although being old, things in that post still applies. In particular:
use a single connection to avoid explosion of requests, and left free the other ones for other tasks (i.e. avoid to use all the 2-to-8 max parallel browser http connections);
reuse data from a previous requests (i.e., if your request is a substring of the previous one, you may already have the suggestions, hence just filter them client-side).
Other things that come to my mind are:
use a Timer to simulate a little delay in case of fast writers, so you call the server only after a bit (probably an over optimization, but still an idea);
allow to fetch suggestions only on a minimum input length (say, min 3 characters). If you have a lot of possible suggestions, the data returned might be expensive even to parse, specially if - for the search - you decide to adopt a contains instead of startswith strategy;
in case you still have tons of suggestions, you could try to implement a lazy load SuggestionDisplay that simply show you the first, say, 50 suggestions and then, on scroll, all the others in an incremental way using the same input string.
Can't say anything from the GWTP part, I've never used it. But AFAICS seems just like GWT-RPC + dispatch mechanism (command pattern) like the old gwt-dispatch. Should't be hard to use instead of vanilla GWT-RPC.
Also have a look at the other 2 previous articles linked in the one above. Might contain some other useful tips.
Use key Up handler instead of key down handler may be it will solve your problem.
this is because keyDown event is fired before rendering the character.
When you submit sorties to Jbehave with
#Override
public InjectableStepsFactory stepsFactory()
{
return new InstanceStepsFactory(configuration(),
new LoginSteps(), new PreferencesSteps(), new BetterSteps());
}
They are executed in BetterSteps, LoginSteps, PreferencesStpes fasion.
How do I make these classes having scenarios execute in a custom order which is not alphabetical?
Say LoginSteps followed by PreferenceSteps followed by BetterSteps etc?
There is a work around for your problem..
You can make your story name starting from Sn where n is 1,2,3..... like S1_LoginSteps, S2_PreferenceSteps
Jbehave will execute stories alphabetical starting from S1 then S2....
Do I understand you correctly that you have steps with identical or similar patterns in all of these steps classes and want to control which of them are used over others?
If so, have a look at step prioritization here: http://jbehave.org/reference/stable/prioritising-steps.html and apply priorities to your preferred steps.
I've been looking for a script that combines the autoGrowInput with the JEditable but found none.
Use https://github.com/MartinF/jQuery.Autosize.Input initialized automatically via jEditable's event data:
jQuery(element).editable(save_fn, {
data: function(value,settings} {
var target = event.target;
window.setTimeout(function(){
jQuery(target).find('input').autosizeInput();
});
return value;
}
});
It's worth noting that this event (data) fires before the input element is actually created, hence the use of the timeout. There doesn't seem to be an event available at the present time for after the input has been created.
Actually I have created a plugin that does exactly that. You can check the demo and the documentation. I tried to make it very intuitive. It has ajax capabilities, using the RESTful philosophy. If you liked the animation effect on the autoGrowInput, it will be really easy to add it to the plugin just by changing the css file, using the transition property.
If I get people to like it, I may be able to improve and add more features to it. Hope it helps.
I'm looking for someone to point me in the right direction (link) or provide a code example for implementing a drop down list for a many-to-one relationship using RequestFactory and the Editor framework in GWT. One of the models for my project has a many to one relationship:
#Entity
public class Book {
#ManyToOne
private Author author;
}
When I build the view to add/edit a book, I want to show a drop down list that can be used to choose which author wrote the book. How can this be done with the Editor framework?
For the drop-down list, you need a ValueListBox<AuthorProxy>, and it happens to be an editor of AuthorProxy, so all is well. But you then need to populate the list (setAcceptableValues), so you'll likely have to make a request to your server to load the list of authors.
Beware the setAcceptableValues automatically adds the current value (returned by getValue, and defaults to null) to the list (and setValue automatically adds the value to the list of acceptable values too if needed), so make sure you pass null as an acceptable value, or you call setValue with a value from the list before calling setAcceptableValues.
I know it's an old question but here's my two cents anyway.
I had some trouble with a similar scenario. The problem is that the acceptable values (AuthorProxy instances) were retrieved in a RequestContext different than the one the BookEditor used to edit a BookProxy.
The result is that the current AuthorProxy was always repeated in the ValueListBoxwhen I tried to edit a BookProxy object. After some research I found this post in the GWT Google group, where Thomas explained that
"EntityProxy#equals() actually compares their request-context and stableId()."
So, as I could not change my editing workflow, I chose to change the way the ValueListBox handled its values by setting a custom ProvidesKey that used a different object field in its comparison process.
My final solution is similar to this:
#UiFactory
#Ignore
ValueListBox<AuthorProxy> createValueListBox ()
{
return new ValueListBox<AuthorProxy>(new Renderer<AuthorProxy>()
{
...
}, new ProvidesKey<AuthorProxy>()
{
#Override
public Object getKey (AuthorProxy author)
{
return (author != null && author.getId() != null) ? author.getId() : Long.MIN_VALUE;
}
});
}
This solution seems ok to me. I hope it helps someone else.