简体   繁体   中英

GWT - Structure of a html file for my flowpanel

I have a Flowpanel with some listboxes and labels in it:

 private ListBox lbStartHour = new ListBox();
 private ListBox lbStartMin = new ListBox();
 private ListBox lbPauseMin = new ListBox();
 private ListBox lbEndHour = new ListBox();
 private ListBox lbEndMin = new ListBox();
 private DateBox dbxDate = new DateBox();
 private Button OK = new Button();
 private Label lblError = new Label();
 private Label lblStart = new Label();
 private Label lblPause = new Label();
 private Label lblEnd = new Label();
 private Label lblHour = new Label();
 private Label lblMin = new Label();
 private Label lblDate = new Label();

flowpanel.add(lblHour);
    lblHour.setText("Stunden: ");
    flowpanel.add(lblMin);
    lblMin.setText("Minuten: ");
    flowpanel.add(lbStartHour);
    flowpanel.add(lbStartMin);
    flowpanel.add(lbPauseMin);
    flowpanel.add(lbEndHour);
    flowpanel.add(lbEndMin);
    flowpanel.add(dbxDate);
    dbxDate.setFormat(new DateBox.DefaultFormat(DateTimeFormat.getFormat("dd/MM/yyyy")));
    flowpanel.add(OK);
    OK.setText("Buchen");
    flowpanel.add(lblError);    
    lblError.setText("");
    flowpanel.add(lblDate);
    lblDate.setText("Datum: ");
    flowpanel.add(lblStart);
    lblStart.setText("Beginn: ");
    flowpanel.add(lblPause);
    lblPause.setText("Pause: ");
    flowpanel.add(lblEnd);
    lblEnd.setText("Ende: ");

Then I have a .html file with a certain structure like this:

<table id="mainTable" style="padding-bottom: 50px">
<tr>
    <td></td>
    <td id="lblHour"></td>
    <td id="lblMin"></td>
</tr>
  <tr>
    <td id="lblStart"></td>
    <td id="lbStartHour"></td>
    <td id="lbStartMin"></td>
  </tr>      
  <tr>
    <td id="lblPause"></td>
    <td></td>
    <td id="lbPauseMin"></td>
  </tr>
  <tr>
    <td id="lblEnd"></td>
    <td id="lbEndHour"></td>
    <td id="lbEndMin"></td>
  </tr>
  <tr>
    <td id="lblDate"></td>
    <td id="dbxDate"></td>
    <td></td>
    <td id="OK"></td>
  </tr>
  <tr>
    <td id="timeBx"></td>
  </tr>
  <tr>
    <td id="error" colspan="5"></td>
  </tr>
</table>

In my rootpanel I just can use RootPanel.get("lblHour").add(lblHour); to "bind" it to my java code but how am I able to do exact the same with my FlowPanel?

Your approach of mixing and matching gwt java code with html needs to be seen in the context of GWT's UiBinder .

GWT's UiBinder gives you the flexibility of using css/html and allows you to plugin in gwt widgets.

Try avoiding fetching elements in RootPanel one cell from a table and trying to stuff items into it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM