1

I've implemented a MatchPage which displays the following informations:

  • MatchStatus (OPEN/CLOSED)
  • Winner (Name of the Winner)
  • Form to upload files

(follow the link to see how it looks like, [1]: http://www10.pic-upload.de/25.04.13/klmy9fe8cgk3.png)

Now here comes the problem. Let's assume, someone is reporting a result while another one has currently open the specific MatchPage. When the report is done, the MatchStatus will change from OPEN to CLOSED, the color will change from OPEN=green to CLOSED=red, the Winner will be set and the Form for uploading files will disappear (see [2]: http://www7.pic-upload.de/25.04.13/9diu5bcbws9.png).

The player who reported the result will see the updated MatchPage while the other one will still see the old version of the MatchPage, even if he refreshed the browser.

I could solve the problem with OPEN/CLOSED by using my own LoadableDetachableModel:

@Override
public String load()
{
    Match m = dao.getMatchFromID(match_id);
    String result = "OPEN";

    if (m.getClosed())
    {
        result = "CLOSED";
        reportForm.setVisible(false); //does not work
        colorBehavior.setColor("red"); //does not work

    }

    return result;
}

Label on my MatchPage:

matchStatus = new Label("matchStatus", new MyMatchModel(m.getMatch_id(), matchDAO, reportForm));

As you can see on the load() method, setting the reportForm invisible and setting the color to red does not work.

Any idea how i can solve such kind of problem? How can i make the form disappear and change the color to red when the user pressed F5/refresh the browser.

4

1 回答 1

1

You should override the "isVisible()" method of the form like this:

public boolean isVisible() {
  return !yourModel.getObject().getClosed();
}
于 2013-04-26T00:30:43.083 回答