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: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]