Dynamic Markup?

2007-08-15 Thread Brian Gorman
I am writing an open source Wiki component for Wicket..

http://sourceforge.net/projects/wicketwiki

I've recently started it so it is still in the development process.

I want to make it work completely off of AJAX in order for the component to
be completely autonomous without effecting the other components it could be
grouped with inside an application.

Right now, all it does is allow you to edit/render a single wiki page with
no interwiki links.  I accomplish this by simply just using a Label and not
escaping the HTML that is rendered from my wiki engine.  The problem is that
if I want interwiki links I'm going to have to be able to dynamically create
and add AjaxLinks from the rendered HTML markup coming out of the wiki
engine.

I need a way that I can create my own Markup file/stream/whatever and have
my custom component use that dynamic markup instead of searching for a valid
.html file in the classpath.

Does anyone know what I should look into?

Brian Gorman


Re: Dynamic Markup?

2007-08-15 Thread Igor Vaynberg
see kronoscms in wicket-stuff for ideas

-igor


On 8/15/07, Brian Gorman <[EMAIL PROTECTED]> wrote:
>
> I am writing an open source Wiki component for Wicket..
>
> http://sourceforge.net/projects/wicketwiki
>
> I've recently started it so it is still in the development process.
>
> I want to make it work completely off of AJAX in order for the component
> to
> be completely autonomous without effecting the other components it could
> be
> grouped with inside an application.
>
> Right now, all it does is allow you to edit/render a single wiki page with
> no interwiki links.  I accomplish this by simply just using a Label and
> not
> escaping the HTML that is rendered from my wiki engine.  The problem is
> that
> if I want interwiki links I'm going to have to be able to dynamically
> create
> and add AjaxLinks from the rendered HTML markup coming out of the wiki
> engine.
>
> I need a way that I can create my own Markup file/stream/whatever and have
> my custom component use that dynamic markup instead of searching for a
> valid
> .html file in the classpath.
>
> Does anyone know what I should look into?
>
> Brian Gorman
>


dynamic markup and components

2012-02-07 Thread Alinoor
Hi everyone,

I want to load some markup stored in a string, this markup also has
references to wicket components that I need to create and then add to
whatever will contain the markup. Is this possible and how can I do this?

  private static String getHtml() {
String html =
"" +
"my text" +
"" +
"" +
"";
return html;
  }

Cheers,
Alinoor

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/dynamic-markup-and-components-tp4366970p4366970.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: What is Dynamic Markup?

2011-11-10 Thread Martin Grigorov
What is the context ?

On Fri, Nov 11, 2011 at 8:50 AM, raju.ch  wrote:
> Could someone please let me know about  Dynamic Markup?
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/What-is-Dynamic-Markup-tp4030593p4030593.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



Re: dynamic markup and components

2012-02-07 Thread Sven Meier

http://stackoverflow.com/questions/2086732/dynamic-markup-in-wicket

Am 08.02.2012 00:55, schrieb Alinoor:

Hi everyone,

I want to load some markup stored in a string, this markup also has
references to wicket components that I need to create and then add to
whatever will contain the markup. Is this possible and how can I do this?

   private static String getHtml() {
 String html =
 "" +
 "my text" +
 "" +
 "" +
 "";
 return html;
   }

Cheers,
Alinoor

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/dynamic-markup-and-components-tp4366970p4366970.html
Sent from the Users forum mailing list archive at Nabble.com.

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




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



Re: dynamic markup and components

2012-02-08 Thread Alinoor
Hi Sven,

I came across this stackeroverflow link and tried it but couldn't get the
markupcontainer to load the markup. I'll give it another go...

Alinoor

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/dynamic-markup-and-components-tp4366970p4368873.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: dynamic markup and components

2012-02-08 Thread Alinoor
Hi,

Managed to get this working by using a Panel instead of a
WebMarkupContainer. Here's the code.


import org.apache.wicket.MarkupContainer;
import org.apache.wicket.markup.IMarkupResourceStreamProvider;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.util.resource.AbstractResourceStream;
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

public class WicketHtmlContainer extends Panel implements
IMarkupResourceStreamProvider {
  public WicketHtmlContainer(String id) {
super(id);
Form form = new Form("form");
form.add(new TextField("myinput"));
add(form);
  }

  public IResourceStream getMarkupResourceStream(MarkupContainer container,
Class containerClass) {
System.out.println("calling getMarkupResourceStream()");

return new AbstractResourceStream() {

  public InputStream getInputStream() throws
ResourceStreamNotFoundException {
return new ByteArrayInputStream(getHtml().getBytes());
  }

  public void close() throws IOException {
  }
};
  }
  
  private static String getHtml() {
String html =
"" +
"my text" +
"" +
"" +
"";
return html;
  }
}

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/dynamic-markup-and-components-tp4366970p4369176.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: dynamic markup and components

2012-02-08 Thread Andrea Del Bene

Hi,

I don't know if you might find this helpful, but if your component must 
generate a different markup from request to request, you should 
implements interface IMarkupCacheKeyProvider to avoid markup caching:


 /**
 * Must return null to avoid markup caching
 */
@Override
public String getCacheKey(MarkupContainer arg0, Class arg1) {
return null;
}


Hi,

Managed to get this working by using a Panel instead of a
WebMarkupContainer. Here's the code.


import org.apache.wicket.MarkupContainer;
import org.apache.wicket.markup.IMarkupResourceStreamProvider;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.util.resource.AbstractResourceStream;
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

public class WicketHtmlContainer extends Panel implements
IMarkupResourceStreamProvider {
   public WicketHtmlContainer(String id) {
 super(id);
 Form form = new Form("form");
 form.add(new TextField("myinput"));
 add(form);
   }

   public IResourceStream getMarkupResourceStream(MarkupContainer container,
Class  containerClass) {
 System.out.println("calling getMarkupResourceStream()");

 return new AbstractResourceStream() {

   public InputStream getInputStream() throws
ResourceStreamNotFoundException {
 return new ByteArrayInputStream(getHtml().getBytes());
   }

   public void close() throws IOException {
   }
 };
   }

   private static String getHtml() {
 String html =
 "" +
 "my text" +
 "" +
 "" +
 "";
 return html;
   }
}

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/dynamic-markup-and-components-tp4366970p4369176.html
Sent from the Users forum mailing list archive at Nabble.com.

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




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



Re: dynamic markup and components

2012-02-08 Thread Alinoor
Andrea, yes, I'm sure I would have come across this problem, so thanks for
the tip.

Alinoor

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/dynamic-markup-and-components-tp4366970p4370161.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Dynamic Markup Content in Wicket (1.4+)

2011-09-28 Thread Brown, Berlin [GCG-PFS]
Does anyone have an article on how to add dynamic content such that the
content isn't defined in the markup at compile time.  It is generated at
runtime.
 
For example.
 
Old Way - Listing1
 
 
  
  
   
  

 
...
With dynamic content - Listing2
 
 
   

...
 
I could use an offline, compile time tool to generate the markup and
then add it to my project. But I wanted to see if there is something
more dynamic.
 
I also, could use something like a ListView or Repeater, but I wanted to
avoid that because of legacy java code.  
 
The Java code is structured such that 'containers' has sub-components
'container1' ***
 
It is easier refactor the Java code or have some system to add some kind
of dynamic content that would look like the HTML in Listing1.
 
UseCase: For Igor,
 
The use-case is just as I described, there are some cases where you have
legacy Wicket Java code.   It costs more to modify the Java code and
retest the logic so I wanted to be able to 'refactor' my markup and
clean at least the markup without making major changes to the Java
hierarchy structure.
 
 I want to have a HTML markup that looks like this but would act like
the listing in listing1 above. 
 
   

 
 
 
 


Re: Dynamic Markup Content in Wicket (1.4+)

2011-09-28 Thread Martin Makundi
I remember we discussed it before:

http://apache-wicket.1842946.n4.nabble.com/Wicket-MashUpContainer-td1893282.html



2011/9/29 Brown, Berlin [GCG-PFS] :
> Does anyone have an article on how to add dynamic content such that the
> content isn't defined in the markup at compile time.  It is generated at
> runtime.
>
> For example.
>
> Old Way - Listing1
>
> 
>  
>  
>  
>  
> 
>
> ...
> With dynamic content - Listing2
>
> 
>   
> 
> ...
>
> I could use an offline, compile time tool to generate the markup and
> then add it to my project. But I wanted to see if there is something
> more dynamic.
>
> I also, could use something like a ListView or Repeater, but I wanted to
> avoid that because of legacy java code.
>
> The Java code is structured such that 'containers' has sub-components
> 'container1' ***
>
> It is easier refactor the Java code or have some system to add some kind
> of dynamic content that would look like the HTML in Listing1.
>
> UseCase: For Igor,
>
> The use-case is just as I described, there are some cases where you have
> legacy Wicket Java code.   It costs more to modify the Java code and
> retest the logic so I wanted to be able to 'refactor' my markup and
> clean at least the markup without making major changes to the Java
> hierarchy structure.
>
>  I want to have a HTML markup that looks like this but would act like
> the listing in listing1 above.
> 
>   
> 
>
>
>
>
>

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



Re: Dynamic Markup Content in Wicket (1.4+)

2011-09-28 Thread Igor Vaynberg
any component can implement IMarkupResourceStreamProvider and return
whatever markup it wants wicket to use. If you need a fine-tuned
control over the caching mechanism for this markup you can also let
your components implement IMarkupCacheKeyProvider.

-igor


On Wed, Sep 28, 2011 at 8:05 PM, Brown, Berlin [GCG-PFS]
 wrote:
> Does anyone have an article on how to add dynamic content such that the
> content isn't defined in the markup at compile time.  It is generated at
> runtime.
>
> For example.
>
> Old Way - Listing1
>
> 
>  
>  
>  
>  
> 
>
> ...
> With dynamic content - Listing2
>
> 
>   
> 
> ...
>
> I could use an offline, compile time tool to generate the markup and
> then add it to my project. But I wanted to see if there is something
> more dynamic.
>
> I also, could use something like a ListView or Repeater, but I wanted to
> avoid that because of legacy java code.
>
> The Java code is structured such that 'containers' has sub-components
> 'container1' ***
>
> It is easier refactor the Java code or have some system to add some kind
> of dynamic content that would look like the HTML in Listing1.
>
> UseCase: For Igor,
>
> The use-case is just as I described, there are some cases where you have
> legacy Wicket Java code.   It costs more to modify the Java code and
> retest the logic so I wanted to be able to 'refactor' my markup and
> clean at least the markup without making major changes to the Java
> hierarchy structure.
>
>  I want to have a HTML markup that looks like this but would act like
> the listing in listing1 above.
> 
>   
> 
>
>
>
>
>

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



Dynamic markup loading & caching in base page

2013-10-03 Thread Bas Gooren

Hi *,

We built an app which has a base page, and several child pages which 
inherit from the base page.
The app is themeable, and one of the requirements of the app is/was that 
these themes should be manageable.

This means we have a set of themes which can be changed on-the-fly.

To add flexibility to our app, a theme can override the html of the base 
page.
To handle the custom html, our base page implements 
IMarkupResourceStreamProvider and IMarkupCacheKeyProvider.


Every user of the app can select a theme, so the theme is determined per 
request.


The cache key is generated based on the theme id and the container class:

@Override
public String getCacheKey( MarkupContainer container, Class< ? > 
containerClass )

{
final Theme theme = getWebsite().getTheme();
return "Theme#" + theme.getId() + "-" + containerClass.getName();
}

The markup resource stream is only "overriden" for the base page:

@Override
public IResourceStream getMarkupResourceStream( MarkupContainer 
container, Class< ? > containerClass )

{
final Theme theme = getWebsite().getTheme();

if( containerClass.equals( WebsiteLayout.class ) )
{
String markup = theme.getMarkup();
return new StringResourceStream( markup, "text/html" );
}

return defaultResourceStreamProvider.getMarkupResourceStream( 
container, containerClass );

}

(where defaultResourceStreamProvider is a 
DefaultMarkupResourceStreamProvider instance).


The problem we are facing is that when the user switches to a different 
theme, they keep seeing the html code of the previously selected theme. 
Debugging shows that when the theme is changed:

- getCacheKey is hit for both the child page and the base page
- getMarkupResourceStream is hit for both the child page and the base page

I think it could be due to the way wicket's 
DefaultMarkupResourceStreamProvider handles inheritance: maybe it (too) 
caches the base page markup?


Can anyone help with this? How do we properly cache dynamic html for a 
base page which is used by several (static) child pages?


Thanks!

--

Met vriendelijke groet,
Kind regards,

Bas Gooren



Re: Dynamic markup loading & caching in base page

2013-10-03 Thread Bas Gooren

Sorry, I forgot to add that this is a wicket 1.5 app.

As a quick follow-up, after looking at the InheritedMarkupMarkupLoader, 
I see that it delegates loading of the parent (base page) markup to the 
MarkupFactory.


I think that means that our current setup should work, when it doesn't.

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 3-10-2013 18:59, schreef Bas Gooren:

Hi *,

We built an app which has a base page, and several child pages which 
inherit from the base page.
The app is themeable, and one of the requirements of the app is/was 
that these themes should be manageable.

This means we have a set of themes which can be changed on-the-fly.

To add flexibility to our app, a theme can override the html of the 
base page.
To handle the custom html, our base page implements 
IMarkupResourceStreamProvider and IMarkupCacheKeyProvider.


Every user of the app can select a theme, so the theme is determined 
per request.


The cache key is generated based on the theme id and the container class:

@Override
public String getCacheKey( MarkupContainer container, Class< ? > 
containerClass )

{
final Theme theme = getWebsite().getTheme();
return "Theme#" + theme.getId() + "-" + containerClass.getName();
}

The markup resource stream is only "overriden" for the base page:

@Override
public IResourceStream getMarkupResourceStream( MarkupContainer 
container, Class< ? > containerClass )

{
final Theme theme = getWebsite().getTheme();

if( containerClass.equals( WebsiteLayout.class ) )
{
String markup = theme.getMarkup();
return new StringResourceStream( markup, "text/html" );
}

return defaultResourceStreamProvider.getMarkupResourceStream( 
container, containerClass );

}

(where defaultResourceStreamProvider is a 
DefaultMarkupResourceStreamProvider instance).


The problem we are facing is that when the user switches to a 
different theme, they keep seeing the html code of the previously 
selected theme. Debugging shows that when the theme is changed:

- getCacheKey is hit for both the child page and the base page
- getMarkupResourceStream is hit for both the child page and the base 
page


I think it could be due to the way wicket's 
DefaultMarkupResourceStreamProvider handles inheritance: maybe it 
(too) caches the base page markup?


Can anyone help with this? How do we properly cache dynamic html for a 
base page which is used by several (static) child pages?


Thanks!





Re: Dynamic markup loading & caching in base page

2013-10-03 Thread Bas Gooren

Another hour of debugging revealed the problem...

The MarkupCache method loadMarkupAndWatchForChanges has code which 
shortcuts our custom cache key:


// get the location String
String locationString = 
markupResourceStream.locationAsString();

if (locationString == null)
{
// set the cache key as location string, because 
location string

// couldn't be resolved.
locationString = cacheKey;
}

Since our child pages are loaded through wicket's default resource 
loading mechanism, a MarkupResourceStream instance is used.

The MarkupCache has a level of indirection:
cacheKey => locationString
locationString => cached markup

Since our child pages' markup resource stream have a location on disk, 
this effectively means wicket caches the actual content only once 
instead of per theme: all our custom cache keys point to the same 
location string.


The fix was easy: I created an IResourceStreamWrapper class, and let it 
wrap the MarkupResourceStream of child pages. This effectively makes 
them return a null location string, and thus the child pages are cached 
per theme.


Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 3-10-2013 19:11, schreef Bas Gooren:

Sorry, I forgot to add that this is a wicket 1.5 app.

As a quick follow-up, after looking at the 
InheritedMarkupMarkupLoader, I see that it delegates loading of the 
parent (base page) markup to the MarkupFactory.


I think that means that our current setup should work, when it doesn't.

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 3-10-2013 18:59, schreef Bas Gooren:

Hi *,

We built an app which has a base page, and several child pages which 
inherit from the base page.
The app is themeable, and one of the requirements of the app is/was 
that these themes should be manageable.

This means we have a set of themes which can be changed on-the-fly.

To add flexibility to our app, a theme can override the html of the 
base page.
To handle the custom html, our base page implements 
IMarkupResourceStreamProvider and IMarkupCacheKeyProvider.


Every user of the app can select a theme, so the theme is determined 
per request.


The cache key is generated based on the theme id and the container 
class:


@Override
public String getCacheKey( MarkupContainer container, Class< ? > 
containerClass )

{
final Theme theme = getWebsite().getTheme();
return "Theme#" + theme.getId() + "-" + 
containerClass.getName();

}

The markup resource stream is only "overriden" for the base page:

@Override
public IResourceStream getMarkupResourceStream( MarkupContainer 
container, Class< ? > containerClass )

{
final Theme theme = getWebsite().getTheme();

if( containerClass.equals( WebsiteLayout.class ) )
{
String markup = theme.getMarkup();
return new StringResourceStream( markup, "text/html" );
}

return defaultResourceStreamProvider.getMarkupResourceStream( 
container, containerClass );

}

(where defaultResourceStreamProvider is a 
DefaultMarkupResourceStreamProvider instance).


The problem we are facing is that when the user switches to a 
different theme, they keep seeing the html code of the previously 
selected theme. Debugging shows that when the theme is changed:

- getCacheKey is hit for both the child page and the base page
- getMarkupResourceStream is hit for both the child page and the base 
page


I think it could be due to the way wicket's 
DefaultMarkupResourceStreamProvider handles inheritance: maybe it 
(too) caches the base page markup?


Can anyone help with this? How do we properly cache dynamic html for 
a base page which is used by several (static) child pages?


Thanks!