auto refresh on wicket page - wicket

I have scenario to auto refresh the wicket page but it is base page and all pages are extending it .I dont want refresh all extending pages only base page.
right now I am using html meta tag.It is refreshing all the pages.Is it possible to refresh only base page

When you have a
public class BasePage extends Page
and then another
public class SubPage extends BasePage
you don't actually get them as separate pieces. This method of class (and markup) extending only exists to make the process more "object" and "java" like. In the end, the entire page hierarchy is combined together to a single, rendered page.
Now, if you want one sub-part of the page to refresh, I suggest creating a Panel and adding an AjaxSelfUpdatingTimerBehavior to that component. This will let you auto refresh any part (or multiple parts) of a page without the entire thing re-rendering.

First off I agree with #jbrookovers suggestion.
However, If you do actually want the hole page to refresh, Why not create a new class RefreshingBasePage? Then just move your <meta refresh....> to the new classes .html file. Just insert the refresh into the head via a <wicket:head></wicket:head> element.
Then you can leave your other pages free to inherit from BasePage without the refresh getting in the way.

Related

AEM CQ5 How to modified a parent page and at meantime the child page get modiedly automatically

How to modified a parent page and at meantime the child page get modified automatically? without use the MSN livecopy , because we don't have the license.
anyone can help ? thank you very much.
For example, I want to change a text value in parent page, and meanwhile I want the same text in child page could be changed automatically.
Not sure if I understand you right, but I see two possibilities:
iparsys: This is an inheriting parsys. So any component placed within this will be inherited to child pages. You can break the inheritance on any level
Reference: There is a Reference component in the foundation where you can reference any component from another page by its path.
In both cases, if the original component gets changed, the inheriting or referencing page will get the update as well.

overriding setResponsePage() to build breadcrumb

I 'm trying to build my own simple breadcrumb component that pushes a PageRefence onto a List for each and every Link in the application.
Unfortunately, setResponsePage() is final (I use wicket 6).
The only other option that comes to my mind is to add a parameter to my base page constructor. But this would require me to change every link in the app..
Are there any other options?
Since you already have a base page, it's easier to override onBeforeRender() in your base page to update the breadcrumbs list that you'd store in your Session object.
Or am I missing something?
To answer my own question:
In the end I realized, that I do not want to have the breadcrumb updated on each new page.
Therefore I created an object that holds a List of Pagereferences. When I navigate to a new Page, I take the list of the current page, make a copy of it an add the current page. The resulting list is pased onto the new page.
All this is handeld in the base page.
Keeping it in the page, avoids problems with multiple tabs / windows.
Thanks for the help.

To know if its a new page in ITEXT pdf

I am generating a pdf using itext. So when the content of a page exceeds it creates a new page automatically. I am trying to know if it created a new page. If yes I want to add some image on top of the page.
List paylist =new List(List.ORDERED, List.ALPHABETICAL);
paylist.setIndentationLeft(10);
paylist.add(new ListItem("Some text", yourfont));
document.add(paylist);
The content of the list will be dynamic. So I am unable to find whether its a new page it is in the same page. Suggestion please..
Subclass PdfPageEventHelper and bind an instance of it to your PdfWriter:
writer.setPageEvent(new YourCustomPageEventHelper());
Within that class there's a method called onStartPage that will be called for every page in your document. Use this to add an image to every page, then you don't have to worry about keeping tracking of things. See this page for a bunch of samples.
Check the page number before and after you add content to the document. If the value is different, then a new page has been created.
The page number is returned by the PdfWriter.getPageNumber() method.

Nvigation within a GWT application

I intend to build a web application where users can enter their time every week and have been struggling to get my head around the concept of a single page in GWT that gets repainted with data depending on the user actions. After researching a lot on this site and google, I found one link that I would like to emulate but dont know how to go about doing it in GWT. Although their source code is available, I dont think it is full and complete. I got some idea from this link - Multiple pages tutorial in Google Web Toolkit (GWT) but again dont know how to implement it into a working version. One small working sample would be great to help me understand and get started.
Could anyone please guide me as to how to achieve the look and feel of the screen with the link below and how the content can be repainted with data from the server ? Would I need to put all the logic in one EntryPoint class ? I would like to have the hyperlinks in the left navigation panel and show the content in the right panel. I seem to be completely lost after a few hours of research.
http://gwt.google.com/samples/Showcase/Showcase.html#!CwHyperlink
Thanks a lot for your help.
Regards,
Sonu.
A single page application layout is actually quite easy to achieve.
The first thing you do is define the general layout, using GWTs layout panels. For your layout, I'd suggest using a DockLayoutPanel.
Content content = new Content();
Button switchContent = new Button(content);
Navigation navigation = new Navigation();
navigation.add(switchContent);
DockLayoutPanel pageLayout = new DockLayoutPanel(Unit.EM);
p.addWest(new HTML(navigation), 7.5);
p.add(new HTML(content));
Here, the width of the navigation panel will be fixed, whereas the content will take the remaining space. You have to pass a reference of the button (or some other widget) which does the switch of the content area, add the button to the navigation area, and so on.
Put this into a class, e.g. called MasterPageFactory:
public class MasterPageFactory {
private MasterPageFactory() {}
public static MasterPage newInstance() {
Content content = new Content();
Button switchContent = new Button(content);
Navigation navigation = new Navigation();
navigation.add(switchContent);
DockLayoutPanel masterPage = new DockLayoutPanel(Unit.EM);
masterPage.addWest(new HTML(navigation), 7.5);
masterPage.add(new HTML(content));
return masterPage;
}
}
Now, in your EntryPoint class, call the factory:
RootLayoutPanel.get().add(MasterPageFactory.newInstance());
This example should get you an idea. Other options would be using a DI framework like Guice or the Command pattern.
Your question is mixing up a couple of concepts. If you want the user to click something that looks like a link, and in reponse the application sends a request to the server and shows a page that looks different than the page they're on, and that page has fresh data that just came from the server, then you want a perfectly normal anchor or form submit button. You don't need anything special or weird from GWT.
The showcase example you referenced lets the user click something that looks like a link, and looks like it loads a new page, even to the point of letting the back button work as expected, but does not actually hit the server to get a new page or new data.

How to get a Listener in Eclipse FormPage

I am adding 3 pages inside an editor through Eclipse's FormPage. Now on selecting each page I want a listener to get fired. I tried to implement IPageListener in each page class, but none of them responded me. How to get the listener while selecting any page in eclipse FormPage?
I have made a FormEditor class,
public class SimpleFormEditor extends FormEditor
Then I added addPage inside it,
addPage(new ApplicationFormPage(this));
Now in this ApplicationFormPage, I implemented IPageListener,
public class ApplicationFormPage extends FormPage implements IPageListener{
Actually my plan is to get the listener as soon as we click on this page tab.
When your form page is instantiated, you need to add it to something in order to get notified of page changes. In MultiPageEditorPart they use org.eclipse.jface.dialogs.IPageChangedListener.
formEditor.addPageChangedListener(page);