Can the headers of an AjaxFallbackDefaultDataTable be updated via AJAX? - java

I'm currently writing a web application. I am using an AjaxFallbackDefaultDataTable to display domain objects. The tables include pagination and so far everything works just fine.
What I want to be able to do:
In my implementation of IColumn<T> I am returning my own header component via Component getHeader(String componentId). This component depends on the page and page size which is currently used by the table (it shows a link to another page which should only care about the current slice of data). Now, I have implemented the void onPageChanged() method of the table so that it updates the columns accordingly.
Problem:
I am using the Wicket AJAX debug window and it shows me that the whole table is rerendered on the server and sent to the client. However, the headers doesn't seem to update correctly so that I'm forever stuck with page 0. Using a debugger I can clearly see that Component getHeader(String componentId) is only called once, when the table is created initially.
Question:
Is there any way I can solve this issue without writing my own implementation of an AJAXified data table? If not, can somebody please point me in the right direction?

HeadersToolbar creates the headers once only.
Either you implement your own toolbar recreating the headers before each render, or rewrite your header component to always render an up-to-date link.

Related

Eclipse Web Service Explorer not displaying list of Objects as response

I have a basic SOAP based web service. I am able to invoke methods and add information to it. But, while retrieving , the data a single class object seems to be perfectly displayed in the WSE browser. But If I have a list of objects, then I am not able to get any response in the body. Not sure, whats going wrong. Even the logs in console don't throw any error.
IS there a better way to view list of objects in WSE ?
Try clicking the Source link (to the right of the body) to check if the SOAP Response Envelope indeed has multiple objects in it. If it has, you may have encountered a bug in the viewer, if it doesn't - either the service doesn't work as expected, or your Request is not proper.
I tested locally with the following public service (operation getAll):
http://www.predic8.com:8080/crm/CustomerService?wsdl
It returns a list of many customers (judging from the raw response), but for me WSE only listed a few of the them (and the indentation depicting the hierarchy is wrong), so I guess this view of WSE is not very reliable.
So I'd suggest sticking to the raw XML view in WSE. In my everyday work I prefer using SOAP UI for service exploring/testing. It is free and gets regularly updated - you might want to check it out.
Good luck!

How to dectect modification on page? Which Listener in java?

Is there any Listener in Java, which can detect, if the content of the page has been changed? "changed" means text in the page has been added/removed...
Process: Author modifys the page and activate it. In publish Instance it must be checked if the page content has been modified/changed
I don't think there is such listener. You're gonna have to reload/access the page or you can hook it up so when the author submits his changes you insert a value to the database that this specific page has been modified. After that you just read the data from the DB using a timer that triggers every now and then and if new line appears you do your action.
This is more of a design question and you should think about what project you're working on and what's the best approach to implement this feature.
Apache sling can handle events. There is nice tutorial here http://sling.apache.org/documentation/tutorials-how-tos/how-to-manage-events-in-sling.html .
Basically create a listener ad check if the event relates to a page node (or its subnode). Then apply whatever logic you want.
Be careful to check whether you are in an author or publish instance ( or turn off the service in author)

GWT/GXT adding nocache.js file, in the header or after the body?

I notice that most GXT/GWT applications put the nocache.js file after the body tag. And few seem to put in the include in the header tag. Why is that?
Given the fact that the GWT script tag will be evaluated synchronously (the tag), but fetched asynchronously (the code, into an iframe), I don't see why not put it as the very first thing. Time saved!
Unless, you have some kind of complex logic that cannot have the chance to be properly displayed before the onModuleLoad() call (e.g., images evaluated but still not fetched), much like Steffen Schäfer pointed out. But you can defer you app startup for them though.
For more info, have a look here.
From my point of view there are 2 cases:
If you use GWT to only enhance your page that is generated on the server side then put the <script> at the end. That allows your browser to render the initial content of the page before parsing the JS code.
If you built a single page application that is completely generated by GWT on the client side, there's no content to be initially shown. In that case you can put the <script> to the head.
Be aware that 1. also applies if you implemented a loading animation or placeholder content to be initially shown.

Mail form in Play Framework 2.0.X

I'm using Play Framework (2.0.4) and I wonder what is the best way to create a page with a form for sending an email. I know that there is a plugin for sending email, so this isn't a problem - I can write the controller with a method which sends the email.
My question is more about the action I should provide (in routes file). Should I create a POST action which takes for arguments (sender name, sender email, subject, body)? or should I somehow create a model object which would be filled in the form and pass to the action in the controller? What is the best practice? And how to glue it properly (how should the action look in the routes file, how should the view look like)?
You need two views - one with form (let's call it mailForm), second - with body (bodyHtml) of the mail. (optionally you can create bodyTxt if you want to send HTML and TXT version.
Dedicated model will be good helper, as it will help you use the Play's Form<T>, also if required you will be able to store sent messages in DB. Anyway you can also operate on the map of Strings - especially if you plan to make many dynamic forms (with unknown number of fields).
After filling the form it will go to for an example sendEmail() action, where you need to fill the Form (bindFromRequest) eventually create the object and save to DB and finally pass to bodyHtml view as argument. Of course instead of returning rendered view as a action's result you should use it with toString - to send it with mailer. The action should return a redirect to some 'Thank you' page. and that's all.
Note: Written fast, if something will be unclear, let me know ...

How can I force Vaadin v8 to update the screen?

I have a small Vaadin v8 application that has several input fields (comboboxes, selectgroups, etc...). The content of most of these is determined by the chosen content of the first ComboBox. However, when I select something in it, all the others stay blank until I click one, at which point they all update. This is not desired behaviour, but I assume it's being caused by the server-side being up to date but not updating the client side view. (Even when adding requestRepaint() in my first Combobox's ValueChangeListener)
There must be some method to force Vaadin to get the data I want it to display even if no other components are clicked?
EDIT
I'm not allowed to post answers to my own question so soon, so I'm putting it here temporarily:
I found that there's a javascript method that synchs client and server.
myComponent.getApplication().getMainWindow().executeJavaScript("javascript:vaadin.forceSync();");
The only problem I have now is that the ValueChangeListener on one of my comboboxes still only fires when I click another combobox (or the same one twice). It's the weirdest thing because the second combobox, when loaded, fires it's event perfectly.
Is the first ComboBox in "immediate" mode?
If not, it probably should be : component.setImmediate(true).
See https://vaadin.com/book/-/page/components.selection.html
I had the same problem, see below how it could be done in version 8.0.5 (from 2017):
#Push
public class WebUi extends UI {
public void fireComponentUpdated() {
getUI().push();
}
}
There is a hack you can use if you have set a datasource for your componets that forces vaadin to re-render them. I use this for updating tables that have dynamic data
yourcomponent.setContainerDataSource(yourcomponent.getContainerDataSource());
Did you requestRepaint on the correct components?
Keep in mind that requestRepaint marks the component as dirty but doesn't mean it will be repainted - a client can only be refreshed when it makes a request to the server.
See this thread https://vaadin.com/forum/-/message_boards/view_message/231271 for more information about your options (it deals with UI refreshes due to background thread processing).
In Vaadin 7 it is enough to put this line in main UI.init(VaadinRequest) method:
UI.getCurrent().setPollInterval( 1000 );
if you want to refresh your UI (in this case) every second. This way you instruct UI to poll server for changes in defined interval.
Beware, excessive server traffic might be a problem if you have lot of users that use your application at the same time.
In Vaadin 6 you will have to play with ProgressIndicator (which could be invisible if you want) and try to do the similar what UI.getCurrent().setPollInterval(int) in Vaadin 7 does.

Categories

Resources