You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alinoor <al...@islamicdesignhouse.com> on 2012/02/08 00:55:15 UTC
dynamic markup and components
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 =
"<form wicket:id=\"form\">" +
"my text" +
"<input wicket:id=\"myinput\" type=\"input\" />" +
"<input type=\"submit\" value=\"submit\"/>" +
"</form>";
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: dynamic markup and components
Posted by Alinoor <al...@islamicdesignhouse.com>.
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: dynamic markup and components
Posted by Andrea Del Bene <ad...@ciseonweb.it>.
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 =
> "<wicket:panel><form wicket:id=\"form\">" +
> "my text" +
> "<input wicket:id=\"myinput\" type=\"text\" />" +
> "<input type=\"submit\" value=\"submit\"/>" +
> "</form></wicket:panel>";
> 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-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
Re: dynamic markup and components
Posted by Alinoor <al...@islamicdesignhouse.com>.
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 =
"<wicket:panel><form wicket:id=\"form\">" +
"my text" +
"<input wicket:id=\"myinput\" type=\"text\" />" +
"<input type=\"submit\" value=\"submit\"/>" +
"</form></wicket:panel>";
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: dynamic markup and components
Posted by Alinoor <al...@islamicdesignhouse.com>.
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: dynamic markup and components
Posted by Sven Meier <sv...@meiers.net>.
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 =
> "<form wicket:id=\"form\">" +
> "my text" +
> "<input wicket:id=\"myinput\" type=\"input\" />" +
> "<input type=\"submit\" value=\"submit\"/>" +
> "</form>";
> 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-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