isackrubio / gwt-cal

Automatically exported from code.google.com/p/gwt-cal
0 stars 0 forks source link

Error when inserting DayView into DockPanel #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Insert a DayView into a DockPanel

What is the expected output? What do you see instead?
A DayView in the DockPanel.Center area of a DockPanel

What version of the product are you using? On what operating system?
Version: GWT - 1.6.4
OS: Windows XP

Please provide any additional information below.
com.google.gwt.core.client.JavaScriptException: (Error): Invalid argument.
 number: -2147024809
 description: Invalid argument.
    at com.google.gwt.dom.client.Element$.setPropertyString$(Native Method)
    at com.google.gwt.user.client.DOM.setElementProperty(DOM.java:1095)
    at
com.google.gwt.user.client.ui.HTMLTable$CellFormatter.setWidth(HTMLTable.java:29
2)
    at
com.bradrydzewski.gwt.calendar.client.DayViewHeader.<init>(DayViewHeader.java:41
)
    at com.bradrydzewski.gwt.calendar.client.DayView.<init>(DayView.java:37)
    at com.bradrydzewski.gwt.calendar.client.DayView.<init>(DayView.java:29)
    at calendar.client.UI_ViewPanel.<init>(UI_ViewPanel.java:48)
    at calendar.client.UI_ViewPanel.getUI_ViewPanel(UI_ViewPanel.java:21)
    at calendar.client.Calendar.onModuleLoad(Calendar.java:77)

Original issue reported on code.google.com by SpaceRoo...@gmail.com on 20 Jul 2009 at 4:18

GoogleCodeExporter commented 9 years ago
I'll try to repeat. I also have an error when trying to add to a RootPanel 
directly.

I have a feeling it is related to the doLayout method (which does the 
appointment 
layout calculations) being called from the constructor ... perhaps a divide by 
zero... 
i'll investigate and see what i can find

Original comment by Brad.Ryd...@gmail.com on 20 Jul 2009 at 5:42

GoogleCodeExporter commented 9 years ago
Did you check the javascript method 'private static native int 
getScrollBarWidth()'
from the WindowsUtils.java with these objects to see if they were returning the 
right
value?

I forgot to mention I only tested the error in hosted mode. I didn't test it in 
a
real browser.

Original comment by SpaceRoo...@gmail.com on 28 Jul 2009 at 11:25

GoogleCodeExporter commented 9 years ago
So I think I found a temporary solution to this problem.  If you add another 
widget
to a panel you are trying to add the DayView to, the DayView won't get -huge 
number
as a size.  

I have a hunch that Google sets the initial size of a lot its panels to REALLY 
REALLY
huge numbers and it throws off your 'private static native int 
getScrollBarWidth()'
method.

Original comment by SpaceRoo...@gmail.com on 10 Aug 2009 at 8:38

GoogleCodeExporter commented 9 years ago
Yes, I can't quite put my finger on what it is, but i put in a temporary 
workaround in r72 that I think fixed the problem.

If the getScrollBarWidth returns a negative number (which was causing the 
error) then it will use a default value of 17px, which seems to be standard on 
all the browsers. If the method returns the default value it does not cache it, 
and the next time the method is called it will re-run the native method.

If you look at line 94 of the ical demo, you will see i'm adding the DayView to 
a doc panel and it seems to work fine:
http://code.google.com/p/gwt-cal/source/browse/trunk/gwt-cal-demo/src/com/bradry
dzewski/gwt/calendar/demo/client/iCalCalendarPanel.java

I'll keep the bug open until I have a better solution, but hopefully this helps 
in the short term

Original comment by Brad.Ryd...@gmail.com on 10 Aug 2009 at 10:04

GoogleCodeExporter commented 9 years ago
FYI, I came across this bug even with the fix above.  It appears to happen 
primarily
on PCs when the scrollbar width is being retrieved when an object (such as 
DayView)
is created in a controller's constructor.  At that time, the scrollbar widths 
aren't
available.  Unfortunately, it doesn't always return a negative number, and in my
case, it simply returned zero (0) - this did not occur on Macs, however.  The 
fix for
us was to modify WindowUtils.java getScrollBarWidth() with the following change:

if(tmpScrollBarWidth<=0)

instead of:

if(tmpScrollBarWidth<0)

After this change, it worked fine.  Normally, I'd be concerned with the 
comparison
matching zero, but a scrollbar width shouldn't be zero anyway (except possibly 
if
there is no scrollbar).

Original comment by 12gaugem...@gmail.com on 16 Dec 2009 at 12:52

GoogleCodeExporter commented 9 years ago
Thanks for providing the fix. I made the change and committed to the 0.9 
branch, r179

Original comment by Brad.Ryd...@gmail.com on 16 Dec 2009 at 6:44