Java Reference
In-Depth Information
DecoratedTabPanel tabPanel = new DecoratedTabPanel();
tabPanel.setWidth("100%");
tabPanel.setAnimationEnabled(true);
tabPanel.add(tab1Content, "Enter Time");
tabPanel.selectTab(0);
The last thing to do in your onModuleLoad method is to add all of your components to
the RootPanel .
// add the navpanel and flex table to the main panel
mainPanel.add(topPanel);
mainPanel.add(tabPanel);
// associate the main panel with the HTML host page.
RootPanel.get("timeentryUI").add(mainPanel);
The Root panel is a special container that sits at the top of the GWT user interface
hierarchy. It's an invisible container for your dynamic elements that is, by default,
wrapped in a <body> element in your HTML host page. You'll make some changes to
your generated host page to wrap the Root panel in a <div> element instead.
One of the major functional requirements for your application is to provide users
with the ability to add new time-entry rows to the timecard. Each row will consist of a
list box for projects, a list box for project-dependent milestones, text boxes for
each day of the week, and a label for the row total. You'll add the following code to
accomplish this task and then we'll look at how to call this method via the Add Row
button click event when you implement listeners for your application. You can add a
call to this method after the Root panel is set, allowing users to see a blank row when
the application initially loads.
It is important to note that the two list boxes are defined as final, which allows
your code to access the components from different methods and to fill their contents
from your server-side code.
private void addRow() {
int row = flexEntryTable.getRowCount();
final ListBox lbMilestones = new ListBox(false);
final ListBox lbProjects = new ListBox(false);
lbProjects.addItem("-- Select a Project --");
// create the time input fields for all 7 days
final TextBox day1 = new TextBox();
105
 
Search WWH ::




Custom Search