Project

General

Profile

Actions

Support #2243

closed

Do NOT display image

Added by Anonymous over 10 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Urgent
Assignee:
Target version:
-
Start date:
09/20/2013
Due date:
% Done:

0%

Estimated time:

Description

I download the hello programme from http://www.webtoolkit.eu/jwt/examples/ , and changed it . But the image is NOT displayed.

How to display the image? Please help me.

The HelloMain.java source:

public class HelloMain extends WtServlet {

private static final long serialVersionUID = 1L;

public HelloMain() {

super();

}

@Override

public WApplication createApplication(WEnvironment env) {

/*

  • You could read information from the environment to decide whether the
  • user has permission to start a new application
    */
    return new HelloApplication(env);
    }
    }

//------------------------------------------------------------------

The HelloApplication.java source

public class HelloApplication extends WApplication {

public HelloApplication(WEnvironment env) {

super(env);

getRoot().addWidget(new WImage(new WLink("icons/wt_powered.jpg")));

getRoot().addWidget(new WText("yeah Your name, please ---0po0 ? "));

final WLineEdit nameEdit = new WLineEdit(getRoot());

nameEdit.setFocus();

WAnchor anchor = new WAnchor(new WLink(http://www.webtoolkit.eu/"), "Wt");

anchor.setTarget(AnchorTarget.TargetNewWindow);

WImage image = new WImage(new WLink("icons/emweb.jpg"), anchor);

getRoot().addWidget(image);

WPushButton button = new WPushButton("yeah Greet me.", getRoot());

button.setMargin(5, Side.Left);

getRoot().addWidget(new WBreak());

final WText greeting = new WText(getRoot());

button.clicked().addListener(this, new Signal.Listener() {

public void trigger() {

greeting.setText("yeah Hello many many there, " + nameEdit.getText());

}

});

}

}

Actions #1

Updated by Wim Dumon over 10 years ago

Hello,

Your code looks ok, apart from a reparenting that is probably not intentional. See my comments in the code below.

Does your browser fetch the images? Can you take a look with your browser's debugger (firebug, or chrome's inspect element, or IE developer tools) to see if the browser requests the image? It is possible that it fetches it from an unexpected path.

public class HelloApplication extends WApplication {
  public HelloApplication(WEnvironment env) {
    super(env);
    // Line below looks ok
    getRoot().addWidget(new WImage(new WLink("icons/wt_powered.jpg")));

    getRoot().addWidget(new WText("yeah Your name, please --0po0 ? "));
    final WLineEdit nameEdit = new WLineEdit(getRoot());
    nameEdit.setFocus();

    WAnchor anchor = new WAnchor(new WLink(http://www.webtoolkit.eu/"), "Wt");
    anchor.setTarget(AnchorTarget.TargetNewWindow);
    // Here you add an image to the anchor, so it will be a clickable image
    WImage image = new WImage(new WLink("icons/emweb.jpg"), anchor);
    // But the line below reparents the image, so that it no longer clickable
    // as anchor image. It becomes a normal image in the dom tree. This is
    // probably not what you want - just remove this line.
    getRoot().addWidget(image);

    WPushButton button = new WPushButton("yeah Greet me.", getRoot());
    button.setMargin(5, Side.Left);

    getRoot().addWidget(new WBreak());

    final WText greeting = new WText(getRoot());

    button.clicked().addListener(this, new Signal.Listener() {
       public void trigger() {
         greeting.setText("yeah Hello many many there, " + nameEdit.getText());
       }
    });
  }
}

BR,

Wim.

Actions #2

Updated by Koen Deforche about 9 years ago

  • Tracker changed from Feature to Support
  • Status changed from New to Resolved
  • Assignee set to Wim Dumon
Actions #3

Updated by Koen Deforche about 9 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF