Wednesday, March 30, 2011

Re: why are important methods in HTMLTable protected?

Look at this: I have a parent widget with an inner class like this:

public class ContainerWidget extends Composite {

private FlowPanel panel = new FlowPanel();

public ContainerWigget() {

//But then, IllegalStateException is thrown here. I don't why

panel.add(new FrontContentPanel());

initWidget(panel);

}

class FrontContentPanel extends HTMLTable {

FlowPanel frontcontentpanel = new FlowPanel();
Grid featureGrid = new Grid(2, 2);

public FrontContentPanel() {

frontcontentpanel.setStyleName("gwt-FrontContentArea");
            
          featureGrid.setBorderWidth(1);
          featureGrid.setCellPadding(3);
          featureGrid.setCellSpacing(3);
          featureGrid.addStyleName("gwt-featureGrid");
          frontcontentpanel.add(featureGrid);

// I can use any of HTMLTable method here once overridden

initWidget(frontcontentpanel);

}
        /*@Override
        public void setCellFormatter(HTMLTable.CellFormatter cellFormatter) {
            
        }

        @Override
        public int getCellCount(int i) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
}

}

When I try to add the inner class to its super (as seen above), I get a IllegalStateException and my app is not initialized.

Alternatively,

public class ContainerWidget extends Composite {

private final FlowPanel panel = new FlowPanel();

public ContainerWidget() {

// Works without issues
panel.add(new FrontContentPanel());

initWidget(panel);

}

class FrontContentPanel extends Composite {

FlowPanel frontcontentpanel = new FlowPanel();
Grid featureGrid = new Grid(2, 2);

public FrontContentPanel() {

frontcontentpanel.setStyleName("gwt-FrontContentArea");
            
          featureGrid.setBorderWidth(1);
          featureGrid.setCellPadding(3);
          featureGrid.setCellSpacing(3);
          featureGrid.addStyleName("gwt-featureGrid");
          frontcontentpanel.add(featureGrid);

// Now I need access to insertCells(), setCellFormatter(HTMLTable.CellFormatter cellFormatter) etc

initWidget(frontcontentpanel);

}

}

}

Then I can't use most of HTMLTable fine methods. If I use a getCellFormatter, where will the values be coming from? It hasn't been set anywhere in my app. Also, do you know if it is possible to have more than one row in a cell; just like the normal HTML table multiple <td> in a <tr>? I can't seem to find any method in HTMLTable or it's subclasses doing this.

Regards

On Wed, Mar 30, 2011 at 9:51 AM, Jens <jens.nehlmeier@gmail.com> wrote:
Sub classes of HTMLTable provide their own Cell/Column/RowFormatters (either the default one or a sub class of the default one). So if you use Grid or FlexTable you only have to call getCell/Column/RowFormatter to style your columns/rows/cells. Why do you want to set a Formatter from outside the Grid/FlexiTable class?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
Odeyemi 'Kayode O.

B.Sc(Hons) Econs, Application Developer & Systems Engineer (Sun Certified Professional),
Oracle Certified Associate, Solaris Systems Administrator, Drupal Developer

Website: http://sinati.com
Socialize with me: http://profile.to/charyorde, http://twitter.com/charyorde,
http://www.google.com/profiles/dreyemi
Skype:drecute

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment