How to add a webpage in a TabPanel in gwt? - java

I am not understanding how to add a webpage inside the tabbed panel so that when I select a tab the webpage should display in there. I am trying to use UiBinder in GWT.
I have 3 pages Page1.java, Page2.java and Page2.ui.xml.
Page1.java contains a TabPanel with 3 tab indexes, so on the index(0) of the tabPanel I want Page2.java to be displayed.
Any help appreciated. Thanks!

You just add widgets to the TabPanel in order of the tabs. So if you want to have the widget from Page2.java (which I am assuming is a Composite widget) to be displayed in the TabPanel with, say, a tab text of "Page 2" you would do the following (in Page1.java):
TabPanel panel = new TabPanel();
panel.add(new Page2(), "Page 2");
For more details and examples I recommend you read the documentation on the TabPanel.
It's also worth mentioning from the documentation:
This widget will only work in quirks mode. If your application is in Standards Mode, use TabLayoutPanel instead.
So if your host page declaration looks like this: <!DOCTYPE html> which means you are in Standards Mode, you should be using the TabLayoutPanel widget.

With the Ui Binder, you could do it like this:
<g:TabPanel>
<g:Tab text="Page 2">
<app:Page2 />
</g:Tab>
<g:Tab text="Page 3">
<app:Page3 />
</g:Tab>
</g:TabPanel>
Inside the tab panel you can place as many tabs as you want. Inside the tab you can place a widget, composite or some panel.
The <app:xxx> tag you define in the <ui:UiBinder> tag at the top of the zzz.ui.xml and could look like this: xmlns:app="urn:import:com.yourproject.package". So every class which lies in this package (and extends Composite (or similar)) can be used in the ui binder this way.
Also see the GWT documentation of the Ui Binder: http://code.google.com/webtoolkit/doc/2.2/DevGuideUiBinder.html

Related

Vaadin: How to navigate without reloading the page?

I have to navigate between my components and I use a custom button like this:
button.addClickListener(click -> {
UI.getCurrent().navigate(ClassToNavigate.class);
});
The url does refresh in the search bar but it only shows a black page, I've to hit F5 to see the component in my parent layout.
My only fix is to add:
UI.getCurrent().getPage().reload();
...which reloads the page after navigating to the URL, and that breaks the UX in my opinion, however... when using a BeforeEnterEvent on a class and using the method:
forwardTo(ClassToNavigate.class);
redirects perfectly... although I can't have BeforeEnterEvent for every menu button I have, I can't see why forwardTo() works perfectly and navigate() doesn't.
Is there a way to navigate without having to reload the page? And without using RouterLink which I can't because I'm already using a custom component.
Thanks in advance!

Programmatically adding text to the editor eclipse plugin

I'm developing an eclipse plugin , and at some point in my plugin , a jframe is opened , and inside the jframe, there is a button . I have added a mouselistener to the button , and when pressed , I want some code to be added to the editor at caret point . but, I get null pointer exception here:
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage();
It appears you don't have an active page. Maybe your Swing based code is displaying a separate window?
Use IWorkbenchWindow.getPages() to get an array of IWorkbenchPage containing all the pages and look through the pages for the one containing the editor you want.

How to make vertical menu using jsf?

i m developing a web page, where i want to show vertical menu. when any clicks on menu its content should open on same page inside a box, and on clicking next menu new content should open in same place . I m using java ,JSP,JSF, java script.. can any one help me on.....
jQuery(document).ready(function(){
$("#myLink").click(function() {
$(this).fancybox({href : 'temp.jsp'});
});
});
Open ajax content
I have tried this but i need to design lots of jsps.
use primefaces menu, it has all the fancy you need
You could also try RichFaces - rich:dropDownMenu and rich:popupPanel
rich:dropDownMenu - RichFaces Showcase
rich:popupPanel - RichFaces Showcase

Refresh only update panel on parent from pop-up window

I have a button which opens a pop-up window and an Ajax update panel. Inside that window I have another button.
What code do I have to run if I want that update panel to be refreshed, when I press the button from the parent page, without refreshing the whole page?
I sow this code on a web which refreshes the page:
<div id="Container" onclick="__doPostBack('UpdatePanel1', '');">
I am such a good friend with Java.
You need to utilize window.opener object.
window.opener.document.getElementById('Container').onclick();
I'd suggest using jQuery to ensure cross-browser compatibility. And also adding some null-checks of course.
Use Jquery :
If the DIV ID remains static :
$("#Container").click(function() {
// REFRESH CONTAINER HERE
});
If the Div ID is dynamic then make use of class instead of ID:
$(".Container").click(function() {
// REFRESH CONTAINER HERE
});

java gwt draw horizontal line

How can I draw a horizontal line in java gwt, something similar to the '< hr >' tag in HTML? I tried it by using
com.google.gwt.user.client.Element bottomLine = DOM.createDiv();
but that somehow doesn't work in IE...
You can use the HTML widget to add whatever html you want inside your page
HTML html = new HTML("<hr style=\"width:100%;\" />")
rootPanel.add(html); // or add it inside another widget
Or you can use css on Panel and define the border-bottom property (if you have a panel that spans the entire page).
Document.get().createHRElement()?

Categories

Resources