Hi,

I am new to wicket. 
I am working on a small scenario, where in I am trying to change the
contents of an html page and navigating to that page while the application
is running.

The code is as follows .....
My first page is Demo.html, in which I am adding a simple link element.

<html>
  <body>
    <div>  Message goes here </div>
    Just test<br>
    Test page
  </body>
</html>




In Demo.java, inside the onclick() event of the 'link' I am trying to add
content to a html file called ShowEnty.html with a component and
initializing the corresponding ShowEnty.java.

public class Demo extends WebPage
{
  File outputFile = new File("C:\\web\\pages\\ShowEntry.html");
  public Demo()
  {
   IModel messageModel = new Model("Hello World!");
   final String compName = "msgInputForm";
   Link link = new Link("link") {
   public void onClick() {
                        
         ShowEntry showEntry = new ShowEntry(compName);
        try{
            FileWriter out = new FileWriter(outputFile);
            out.append("<html><form wicket:id="+compName+"><input type=\"text\" 
             
                      wicket:id=\"messageInput\"/><input type=\"submit\"
value=\"update\"/></form></html>");
            out.close();
        }catch(IOException iox){iox.printStackTrace();}
        setResponsePage(showEntry);
        }
    };
    add(link);
    Label message = new Label("message", messageModel);
    link.add(message);
}



Now the ShowEntry.html looks like the following code with a form, having a
input text field and a submit button (as the contents I was adding from the
onclick() method in the above Demo.java)...

<html>
  <form wicket:id=msgInputForm>
     <input type="text" wicket:id="messageInput"/>
     <input type="submit" value="update"/>
  </form>
</html>



Similarly the ShowEntry.java is as follows

public class ShowEntry extends WebPage{
        
  public ShowEntry(String component) {
        IModel messageModel = new Model("Hello World!");
        add(new MessageForm(component, messageModel));
  }
  private final class MessageForm extends Form
  {
     public MessageForm(String id, IModel model)
        {
            super(id);
            add(new TextField("messageInput", model));
        }

        protected void onSubmit()
        {
             System.out.println("inside submit");
        }
                        
   }
}

My problem now is, as I was writing the html text into the file, I need to
wait to see the contents or probably restart my tomacat.
Is there any way that we can write this html content to the in-memory file
to have the immediate effect instead of writing it to a file on the disk.
-- 
View this message in context: 
http://www.nabble.com/How-to-create-the-webpage%28html%29-on-the-fly-tf4946724.html#a14162959
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to