ajaxTable.setCurrentPage(ajaxTable.getUserRow(user.getUsername(), new
Date(((HomePage)getParent()).getClientCalendar().getTimeInMillis())) /
ROWS_PER_PAGE);

Eeek. Not to be rude, but I really can't read that at all.
Some well-named intermediate variables and a comment might not go amiss.

Your panel is relying on being added to the home page.
This is bad and wrong.

Why don't you pass the calendar into the constructor of the panel?
That would be an awful lot simpler and result in nice readable, correct
code.

I dunno. Give a man a hammer, and everything looks like a thumb...

Regards,

Alastair



On Thu, Apr 3, 2008 at 5:44 PM, Matthew Young <[EMAIL PROTECTED]> wrote:

> During construction of TodayPanel, it hasn't been added to the page yet so
> getParent() is null.  Maybe you should do the 'if(user != null) {...'
> stuff
> in @Override ...onBeforeRender() {...}.  The first time you're okay
> because
> if (user!=null) fails and getParent() is not executed.  The second time it
> gets executes.
>
> On Thu, Apr 3, 2008 at 7:19 AM, Cristi Manole <[EMAIL PROTECTED]>
> wrote:
>
> > Hello,
> >
> > I have a HomePage where, in constructor, i add a Panel :
> >
> >    public HomePage(final PageParameters parameters) {
> >        Date clientDate = getClientCalendar().getTime();
> >        Label label = new Label("today", "Today's Status [" +
> > DateFormat.getDateInstance(DateFormat.SHORT).format(clientDate) + "]");
> >        add(label);
> >        add(reportModalWindow = createReportModalWindow());
> >        add(countButtonsPanel = new CountButtonsPanel("countButtonsDiv",
> > ((WebSession)getSession()).isSignedIn(), this));
> >        add(iSmokedModalWindow = createISmokedModalWindow());
> > *        add(todayPanel = new TodayPanel("todayPanel", new
> > java.sql.Date(clientDate.getTime())));
> > *    }
> >
> > in TodayPanel's constructor, i check if the user is logged, and if he
> is,
> > update an ajax table (current page)
> >
> >        if(user != null) {
> >
> > ajaxTable.setCurrentPage(ajaxTable.getUserRow(user.getUsername(), new
> > Date(((HomePage)getParent()).getClientCalendar().getTimeInMillis())) /
> > ROWS_PER_PAGE);
> >        }
> >
> >
> > When first running the application (no user logged in), today panel is
> > cool.
> > I log in and today panel is correctly updated.
> >
> > Now, when i start *another* browser page and point to the application's
> > url,
> > i get a org.apache.wicket.WicketRuntimeException
> >  because TodayPanel's getParent() returns null.
> >
> > Question is: why?... i could understand it if it were consistent...
> > meaning
> > it will get me null on the first login too.
> >
> > I tested in Firefox tabs.
> >
> > Tks in advance,
> > Cristi Manole
> >
>

Reply via email to