You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by venky221 <ve...@splashnote.com> on 2007/12/05 01:47:12 UTC

How to create the webpage(html) on the fly

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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to create the webpage(html) on the fly

Posted by Eelco Hillenius <ee...@gmail.com>.
> Oh ... you mean to say that once we have a html page with certain components
> then it is not possible to add new components to that existing page at
> runtime.

You need to do that in another way. You need to replace those
components, not the markup. Panels are convenient for that case. For a
simple example, look at how TemplatePage in wicket-examples/ template
works, particularly the changeAdLink.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to create the webpage(html) on the fly

Posted by venky221 <ve...@splashnote.com>.
Oh ... you mean to say that once we have a html page with certain components
then it is not possible to add new components to that existing page at
runtime.

~Venkat


Eelco Hillenius wrote:
> 
> That's an entirely wrong way of doing things. You should view your
> templates like you would view Java files. Once you deploy your
> application, you don't change those. Instead learn how to use panels
> and maybe component replacement.
> 
> Eelco
> 
> On Dec 4, 2007 4:47 PM, venky221 <ve...@splashnote.com> wrote:
>>
>> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-create-the-webpage%28html%29-on-the-fly-tf4946724.html#a14184557
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to create the webpage(html) on the fly

Posted by Eelco Hillenius <ee...@gmail.com>.
That's an entirely wrong way of doing things. You should view your
templates like you would view Java files. Once you deploy your
application, you don't change those. Instead learn how to use panels
and maybe component replacement.

Eelco

On Dec 4, 2007 4:47 PM, venky221 <ve...@splashnote.com> wrote:
>
> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org