Can I use GWT frame widget inside a PopupPanel? - gwt

I'd like to use a Frame widget inside a PopupPanel widget, so that in this popup I'm able to access some information from a different URL.
public class MyPopup extends PopupPanel {
public MyPopup() {
super(true);
Frame frame = new Frame();
frame.setUrl("http://google.com");
frame.setWidth("200px");
frame.setHeight("100px");
setWidget(frame);
}
}
When I debugged the code, I noticed that the page inside the frame was actually loaded, but I didn't see the content shown. The popup was transparent.
Anyone has experience on this? And any help would be appreciated.
Thanks.

I have used another way to implement my feature, maybe frame+popup is not good way. I will investigate further and see what is the problem.

Related

GWT Nothing shows up after changes

I am learning GWT Widget. I am having a simple EntryPoint class using which I am adding a Widget(ToggleButton). Initially it was working. Then I have just added the changes to change the attributes of my button. Then nothing came up in the specific HTML. I have done a clean-build too.
Below is my onModuleLoad()
#Override
public void onModuleLoad()
{
// Create Instance for your Widget
ToggleButton aToggleButton = new ToggleButton("Normal State", "Clicked State");
// Apply required style as per your wish
aToggleButton.setPixelSize(50, 10);
aToggleButton.setTitle("My first Simple Widget");
// Add it to the panel of your wish
RootPanel.get().add(aToggleButton);
}
Am I missing something. But I am sure that I haven't done anything apart from adding the lines that setting the size and title.
There's nothing wrong with this code. Compile to javascript, clean browser cache and try again.

bugs about using DataGrid wrapped by StackLayoutPanel

I tried to use DataGrid and put it in the stacklayoutpanel.At the time when I provide the data for the ListDataProvider, the CellTable is not visible in the browser because it's on a non active tab (although it's visible in the DOM tree). After switching to the tab containing the CellTable there is no data in it. If the tab is active at time of data provisioning the table is filled correctly. Since I have made a column sortable, if I clicked the sorting, the data would be displayed correctly. I want the data to be displayed automatically when I click the other inative tab. This will not be the problem if I switch to use celltable.
I knew this was the bug in GWT and it is fixed in GWT 2.5 RC. But my boss does not want me to use GWT2.5RC yet. I have to workaround to fix this. I knew that someone said datagrid.redraw() could sort of fix it. I tired it, but the display is weird. For example, I have 10 rows in DataGrid, after selecting the 2nd tab, redraw() is called, the data is automatically displayed, but there is only like 10px of block displaying the data and the scroll bar. I have to scroll down to see other rows. There are lots of space in the bottom of the tab not being used. Could anyone tell me how to fix this? So did I use the wrong way to fix it?
is there anything else I can do to fix this problem.
Could anyone give me some tips please.
Thanks
Best Regards
I have been struggled with this thing for almost 3 days. Thanks for Papick G. Taboada and Thomas Broyer.
You guys' ideas are really helpful. Bascially either of your solution does not solve the problem. but after I combined both solutions, dang~ it worked!!.
So. the completed solution is that, add the selection handler on the non-active tab, then when the event is called, used datagrid.onResize() and then stackLayoutPanel.forcelayout(). This can solve my problem. I have also tried replacing datagrid.onResize() with datagrid.redraw(). It works as well.
I hope this can help other people who have the same problem before using GWT 2.5RC
I came across this problem with a DataGrid within and Panel that was in a StackPanelLayout. DataGrid implements RequiresResize, so I made the Panel that contained the DataGrid implement RequiresResize so it could call onResize() for the DataGrid.
in the Panel that contained the DataGrid
#Override
public void onResize()
{
dataGrid.onResize();
}
On the StackLayoutPanel
stackLayoutPanel.addSelectionHandler(new SelectionHandler<Integer>() {
// http://code.google.com/p/google-web-toolkit/issues/detail?id=6889
#Override
public void onSelection(SelectionEvent<Integer> event) {
Integer selectedItem = event.getSelectedItem();
StackLayoutPanel panel = (StackLayoutPanel) event.getSource();
Widget selectedWidget = panel.getWidget(selectedItem);
if (selectedWidget != null && selectedWidget instanceof RequiresResize)
{
((RequiresResize)selectedWidget).onResize();
}
}
});
I believe a more general answer would be that any container in a StackLayoutPanel that contains a widget that implements RequiresResize should also implement RequiresResize and pass it on.

Get the GWT ScrollPanel to start its vertical scrollbar at the bottom

I know there are some questions out there about the GWT ScrollPanel and how it works, but allow me to explain the situation.
I'm working on a project to implement QoS on routers. I'm now at the developping stage of the project and I need to make a webinterface to add protocols such as ssh and http and give them their bandwidth.
To save memory usage and network traffic, I do not use GWT-EXT or Smart GWT. So to set the bandwidths I use a ScrollPanel with an empty SimplePanel in it (which is way too big), leaving only the scrollbar.
Now here's the problem:
I want each scrollbar for each added protocol to start at the bottom, not the top. I can get it working through the code if I manually move the scrollbar first, then any function works, like a scrollToBottom(), or a setScrollPosition(). If I want to move scrollbars through code before moving the scrollbar manually, however, I can't call a function on it.
(I would post a picture but I can't yet - new user)
Summary:
So if I add a protocol (using a button called btnAjouter), the two slidebars (One for guaranteed bandwidth and one for the maximum bandwidth) for each protocol start at the top. I want them to start at the bottom on the load of the widget.
Is there a way to do this?
Thanks in advance!
Glenn
Okay, my colleage found the solution. It's a rather dirty one, though.
The thing is, the functions only work when the element in question is attached to the DOM. I did do a check with a Window.alert() to see if it was attached, and it was. But the prolem was that the functions were called to early, for example on a buttonclick it would've worked. The creation and attachment of the elements all happens very fast, so the Javascript can't keep up, this is the solution:
Timer t1 = new Timer()
{
#Override
public void run()
{
s1.getScroll().scrollToBottom();
s2.getScroll().scrollToBottom();
}
};
t1.schedule(20);
Using a timer isn't the most clean solution around, but it works. s1 and s2 are my custom slidebars, getScroll() gets the ScrollPanel attached to it.
You can extend ScrollPanel and override the onLoad method. This method is called immediately after a widget becomes attached to the browser's document.
#Override
protected void onLoad() {
scrollToBottom();
}
Could you attach a handler to listen to the add event and inside that handler do something like this:
panel.getElement().setScrollTop(panel.getElement().getScrollHeight());
"panel" is the panel that you add your protocol to. It doesn't have to be a ScrollPanel. An HTMLPanel will work.
You can wrap this method in a command and pass it to Schedule.scheduleDeferred if it needs to be called after the browser event loop returns:
Schedule.scheduleDeferred(new Scheduler.ScheduledCommand(
public void execute() {
panel.getElement().setScrollTop(panel.getElement().getScrollHeight());
}
));

Centering PopupPanel doesn't work on first call

I'd like PopupPanel centred in the screen calling the center() method. It is placed incorrectly the first time I load it. All subsequent times, it centers just fine.
It seems like the styles contained in < ui:style> aren't being injected. I've tried creating an interface to the style in the View (per GWT docs) and calling ensureInjected() in the constructor but this has no effect.
How to have consistent centering?
There is a defect which is said to be fixed in GWT 2.5. For me the issue still exists in 2.5, and for my situation the fix was to set width and height of the panel explicitly:
popup.setWidth("800px");
popup.setHeight("700px");
For me, this works with the following simple snippet (tested on Firefox 3.6 and Chrome 10.0):
#Override
public void onModuleLoad() {
final PopupPanel popupPanel = new PopupPanel();
popupPanel.center();
}
Are you doing something differently?

How to force a redraw/re-layout in Ext GWT (GXT)?

In GXT, I've got a control with an important panel added to the bottom component, basically like this:
public class SamplePanel extends ContentPanel {
ContentPanel panel = new ContentPanel();
public SamplePanel() {
setBottomComponent(panel);
}
public void setVisible(boolean isVisible) {
panel.setVisible(isVisible);
}
The panel is being set as the "bottom component" because it needs to stay at the bottom of the widget and viewable at all times.
The problem is, while the visibility of the panel toggles correctly, the 'bottom component' area doesn't resize to become smaller and fit the new dimensions of the bottom area.
However, I've noticed that the bottom area does resize when I manually change the size of the widget with the mouse.
Is there any way to programatically force a redraw/repaint/re-layout... anything to have the bottom component change to reflect the new size of its contents?
I've tried all of these and they don't work:
public void setVisibility(boolean isVisible) {
panel.setVisible(isVisible);
doLayout(true);
recalculate();
repaint();
}
Thanks
In the last gxt you can do.
this.layout(true);
Otherwise you can fire an Events.Resize event.
I don't know about GXT, but in GWT I would use one of the force() or forceLayout() methods on my panel. Perhaps there is a similar API for doing that!
HTH.
Have you tried using the setLayoutOnChange() method of the ConentPanel?
I would suggest looking at this:
http://davidmaddison.blogspot.com/2008/12/gwt-rendering-process.html
What you can try to do is addListeners to the Panel and try calling panel.layout() there
This post claims that the top and bottom components to not participate in layout once the panel has been rendered and suggests a manual workaround (using RowLayout) or manually setting the size of the panel.
Consider finding the sizes from the parent and calling onResize(width, height)