You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martin Makundi <ma...@koodaripalvelut.com> on 2010/02/08 22:06:06 UTC
Wicket without markup
Hi!
I finally came up with something that I have been looking for. It
might be more suitable for Wicket 1.5 because it's not very compatible
(read: not very lean) with current wicket:
Wicket Without Markup ;)
Well, yes there is markup for each component, but when you lay them
out on the page, the markup is component-contained.
So coding an application feels like a breeze for the Java developer,
and the HTML developer can strictly stick to styling the (contained)
components themselves.
Maybe I omitted something, but here comes the example. Let me know
what you think. Does it inspire any fresh ideas in you? Is this an old
idea? I recall listviews having been mentioned once as a solution for
producing markup-less code ... maybe I have re-invented the weel or
something.
HomePage.html:
<html>
<body>
<strong>Wicket Quickstart Archetype Homepage</strong>
<form wicket:id="form">
<wicket:container wicket:id="root-content-id"></wicket:container>
</form>
</body>
</html>
HomePage.java:
public class HomePage extends WebPage {
/** */
private static final long serialVersionUID = 1L;
private final MarkupNoLongerRequiredContainer rootContainer;
private final MarkupNoLongerRequiredContainer row1;
private final MarkupNoLongerRequiredContainer row2;
private final MarkupNoLongerRequiredContainer row3;
private final Form<Void> form;
/**
*
*/
public HomePage() {
add(form = new Form<Void>("form"));
form.add(rootContainer = new
MarkupNoLongerRequiredContainer("root-content-id"));
{
rootContainer.add(row1 = new MarkupNoLongerRequiredContainer());
row1.add(new Label(GID, "Hello world"));
row1.add(0, new Label(GID, "<br/>").setEscapeModelStrings(false));
// Change row before
row1.add(0, new Label(GID, "<br/>").setEscapeModelStrings(false));
// Change row twice before
row1.add(new Label(GID, "<br/>").setEscapeModelStrings(false)); //
Change row once after
}
{
rootContainer.add(row2 = new MarkupNoLongerRequiredContainer());
row2.add(new Label(GID, "Type your name here:"));
row2.add(new InputField(new TextField<String>(GID, Model.of("..."))));
}
{
rootContainer.add(row3 = new MarkupNoLongerRequiredContainer());
row2.add(new Label(GID, "<br/>").setEscapeModelStrings(false)); //
Change row before
row2.add(new InputField(new Button(GID, Model.of("Clickme")) {
@Override
protected void onComponentTag(ComponentTag tag) {
tag.put("type", "button");
super.onComponentTag(tag);
}
}));
}
}
}
InputField.html:
<wicket:panel>
<input wicket:id="generic-child-id"/>
</wicket:panel>
InputField.java:
public class InputField extends Panel {
/** */
private static final long serialVersionUID = 1L;
public <InputFieldDataType, InputFieldType extends
FormComponent<InputFieldDataType>> InputField(InputFieldType
inputFieldType) {
super(MarkupNoLongerRequiredContainer.GID);
add(inputFieldType);
}
}
MarkupNoLongerRequiredContainer.html:
<wicket:panel>
<wicket:container wicket:id="listview-id">
<wicket:container wicket:id="generic-child-id">
</wicket:container>
</wicket:container>
</wicket:panel>
MarkupNoLongerRequiredContainer.java:
public class MarkupNoLongerRequiredContainer extends Panel {
/** */
public static final String GID = "generic-child-id";
/** */
private static final long serialVersionUID = 1L;
private final List<Component> children = new ArrayList<Component>();
public MarkupNoLongerRequiredContainer() {
this(GID);
}
@Override
protected void onBeforeRender() {
super.onBeforeRender();
}
/**
* @param id
*/
public MarkupNoLongerRequiredContainer(String id) {
super(id);
super.add(new ListView<Component>("listview-id", children) {
/** */
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<Component> listItem) {
Component component = listItem.getModelObject();
if (!component.getId().equals(GID)) {
throw new IllegalStateException("Currently handles only children
with id " + GID);
}
listItem.add(component);
}
});
}
public boolean add(Component component) {
return children.add(component);
}
public void add(int index, Component element) {
children.add(index, element);
}
public boolean addAll(Collection<? extends Component> collection) {
return children.addAll(collection);
}
public boolean addAll(int index, Collection<? extends Component> collection) {
return children.addAll(index, collection);
}
public void clear() {
children.clear();
}
public boolean contains(Object o) {
return children.contains(o);
}
public boolean containsAll(Collection<?> collection) {
return children.containsAll(collection);
}
public int indexOf(Object o) {
return children.indexOf(o);
}
public boolean isEmpty() {
return children.isEmpty();
}
public int lastIndexOf(Object o) {
return children.lastIndexOf(o);
}
public ListIterator<Component> listIterator() {
return children.listIterator();
}
public ListIterator<Component> listIterator(int index) {
return children.listIterator(index);
}
public boolean remove(Object o) {
return children.remove(o);
}
public Component remove(int index) {
return children.remove(index);
}
public boolean removeAll(Collection<?> collection) {
return children.removeAll(collection);
}
public boolean retainAll(Collection<?> collection) {
return children.retainAll(collection);
}
public Component set(int index, Component element) {
return children.set(index, element);
}
public List<Component> subList(int fromIndex, int toIndex) {
return children.subList(fromIndex, toIndex);
}
public Object[] toArray() {
return children.toArray();
}
public <T> T[] toArray(T[] a) {
return children.toArray(a);
}
}
**
Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Wicket Stuff Html Validator
Posted by Martijn Dashorst <ma...@gmail.com>.
I am unable to reproduce it. I've downloaded the jar from the
wicketstuff repo and put it in a quickstart and added it as a jar
dependency. I then modified the homepage to look like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
<head>
<title>Wicket Quickstart Archetype Homepage</title>
</head>
<body>
<strong>
<h1>afsdf</h1>
Wicket Quickstart Archetype Homepage</strong>
<span wicket:id="message">message will be here</span>
</body>
</html>
and the html validator works as expected.
Perhaps you could try and download the jar again.
Martijn
Martijn
On Tue, Feb 23, 2010 at 5:53 PM, <MZ...@osc.state.ny.us> wrote:
> I downloaded the jar from wicketstuff repo...
>
> Here is the DTD;
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket=
> "http://wicket.apache.org/" xml:lang="en" lang="en">
>
>
>
>
> Martijn Dashorst <ma...@gmail.com>
> 02/23/2010 05:16 AM
> Please respond to
> users@wicket.apache.org
>
>
> To
> users@wicket.apache.org
> cc
>
> Subject
> Re: Wicket Stuff Html Validator
>
>
>
>
>
>
> Another possibility is that you use a DTD that is not available (xhtml
> 2.0?)
>
> Martijn
>
> On Tue, Feb 23, 2010 at 9:08 AM, Martijn Dashorst
> <ma...@gmail.com> wrote:
>> Strange, at our company the thing works. Did you build the jar
>> yourself? Or did you download it from the wicketstuff repo?
>>
>> Martijn
>>
>> On Mon, Feb 22, 2010 at 10:24 PM, <MZ...@osc.state.ny.us> wrote:
>>> I've added htmlvalidator-1.3.1.jar to my classpath, and the appropriate
>>> code in the application's init method (see link below). I get the
>>> following error when running the app;
>>>
>>> java.io.FileNotFoundException: Could not find dtds folder null
>>>
>>> http://wicketinaction.com/2009/06/wicket-html-validator-12/
>>>
>>>
>>>
>>> Notice: This communication, including any attachments, is intended
> solely
>>> for the use of the individual or entity to which it is addressed. This
>>> communication may contain information that is protected from disclosure
>>> under State and/or Federal law. Please notify the sender immediately if
>>> you have received this communication in error and delete this email
> from
>>> your system. If you are not the intended recipient, you are requested
> not
>>> to disclose, copy, distribute or take any action in reliance on the
>>> contents of this information.
>>
>>
>>
>> --
>> Become a Wicket expert, learn from the best: http://wicketinaction.com
>> Apache Wicket 1.4 increases type safety for web applications
>> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.4
>>
>
>
>
> --
> Become a Wicket expert, learn from the best: http://wicketinaction.com
> Apache Wicket 1.4 increases type safety for web applications
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.4
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
>
>
>
> Notice: This communication, including any attachments, is intended solely
> for the use of the individual or entity to which it is addressed. This
> communication may contain information that is protected from disclosure
> under State and/or Federal law. Please notify the sender immediately if
> you have received this communication in error and delete this email from
> your system. If you are not the intended recipient, you are requested not
> to disclose, copy, distribute or take any action in reliance on the
> contents of this information.
--
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.4 increases type safety for web applications
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.4
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Wicket Stuff Html Validator
Posted by MZ...@osc.state.ny.us.
I downloaded the jar from wicketstuff repo...
Here is the DTD;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket=
"http://wicket.apache.org/" xml:lang="en" lang="en">
Martijn Dashorst <ma...@gmail.com>
02/23/2010 05:16 AM
Please respond to
users@wicket.apache.org
To
users@wicket.apache.org
cc
Subject
Re: Wicket Stuff Html Validator
Another possibility is that you use a DTD that is not available (xhtml
2.0?)
Martijn
On Tue, Feb 23, 2010 at 9:08 AM, Martijn Dashorst
<ma...@gmail.com> wrote:
> Strange, at our company the thing works. Did you build the jar
> yourself? Or did you download it from the wicketstuff repo?
>
> Martijn
>
> On Mon, Feb 22, 2010 at 10:24 PM, <MZ...@osc.state.ny.us> wrote:
>> I've added htmlvalidator-1.3.1.jar to my classpath, and the appropriate
>> code in the application's init method (see link below). I get the
>> following error when running the app;
>>
>> java.io.FileNotFoundException: Could not find dtds folder null
>>
>> http://wicketinaction.com/2009/06/wicket-html-validator-12/
>>
>>
>>
>> Notice: This communication, including any attachments, is intended
solely
>> for the use of the individual or entity to which it is addressed. This
>> communication may contain information that is protected from disclosure
>> under State and/or Federal law. Please notify the sender immediately if
>> you have received this communication in error and delete this email
from
>> your system. If you are not the intended recipient, you are requested
not
>> to disclose, copy, distribute or take any action in reliance on the
>> contents of this information.
>
>
>
> --
> Become a Wicket expert, learn from the best: http://wicketinaction.com
> Apache Wicket 1.4 increases type safety for web applications
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.4
>
--
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.4 increases type safety for web applications
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.4
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Notice: This communication, including any attachments, is intended solely
for the use of the individual or entity to which it is addressed. This
communication may contain information that is protected from disclosure
under State and/or Federal law. Please notify the sender immediately if
you have received this communication in error and delete this email from
your system. If you are not the intended recipient, you are requested not
to disclose, copy, distribute or take any action in reliance on the
contents of this information.
Re: Wicket Stuff Html Validator
Posted by Martijn Dashorst <ma...@gmail.com>.
Another possibility is that you use a DTD that is not available (xhtml 2.0?)
Martijn
On Tue, Feb 23, 2010 at 9:08 AM, Martijn Dashorst
<ma...@gmail.com> wrote:
> Strange, at our company the thing works. Did you build the jar
> yourself? Or did you download it from the wicketstuff repo?
>
> Martijn
>
> On Mon, Feb 22, 2010 at 10:24 PM, <MZ...@osc.state.ny.us> wrote:
>> I've added htmlvalidator-1.3.1.jar to my classpath, and the appropriate
>> code in the application's init method (see link below). I get the
>> following error when running the app;
>>
>> java.io.FileNotFoundException: Could not find dtds folder null
>>
>> http://wicketinaction.com/2009/06/wicket-html-validator-12/
>>
>>
>>
>> Notice: This communication, including any attachments, is intended solely
>> for the use of the individual or entity to which it is addressed. This
>> communication may contain information that is protected from disclosure
>> under State and/or Federal law. Please notify the sender immediately if
>> you have received this communication in error and delete this email from
>> your system. If you are not the intended recipient, you are requested not
>> to disclose, copy, distribute or take any action in reliance on the
>> contents of this information.
>
>
>
> --
> Become a Wicket expert, learn from the best: http://wicketinaction.com
> Apache Wicket 1.4 increases type safety for web applications
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.4
>
--
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.4 increases type safety for web applications
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.4
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Wicket Stuff Html Validator
Posted by Martijn Dashorst <ma...@gmail.com>.
Strange, at our company the thing works. Did you build the jar
yourself? Or did you download it from the wicketstuff repo?
Martijn
On Mon, Feb 22, 2010 at 10:24 PM, <MZ...@osc.state.ny.us> wrote:
> I've added htmlvalidator-1.3.1.jar to my classpath, and the appropriate
> code in the application's init method (see link below). I get the
> following error when running the app;
>
> java.io.FileNotFoundException: Could not find dtds folder null
>
> http://wicketinaction.com/2009/06/wicket-html-validator-12/
>
>
>
> Notice: This communication, including any attachments, is intended solely
> for the use of the individual or entity to which it is addressed. This
> communication may contain information that is protected from disclosure
> under State and/or Federal law. Please notify the sender immediately if
> you have received this communication in error and delete this email from
> your system. If you are not the intended recipient, you are requested not
> to disclose, copy, distribute or take any action in reliance on the
> contents of this information.
--
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.4 increases type safety for web applications
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.4
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Wicket Stuff Html Validator
Posted by MZ...@osc.state.ny.us.
I've added htmlvalidator-1.3.1.jar to my classpath, and the appropriate
code in the application's init method (see link below). I get the
following error when running the app;
java.io.FileNotFoundException: Could not find dtds folder null
http://wicketinaction.com/2009/06/wicket-html-validator-12/
Notice: This communication, including any attachments, is intended solely
for the use of the individual or entity to which it is addressed. This
communication may contain information that is protected from disclosure
under State and/or Federal law. Please notify the sender immediately if
you have received this communication in error and delete this email from
your system. If you are not the intended recipient, you are requested not
to disclose, copy, distribute or take any action in reliance on the
contents of this information.
Re: Wicket without markup
Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Hi!
I don't know of anybody that tried this out.
I tried to make it very easy for everybody to take a test drive,
started a quick-start project at:
* http://code.google.com/p/wicket-mashup/
**
Martin
2010/2/22 petar <pe...@yahoo.de>:
>
> Hi Martin,
>
> do you have any news on this subject? E.g. found that you reinvent the wheel
> or started a project with this idea :-)?
>
> Regards,
> Peter.
>
>
> MartinM wrote:
>>
>> Hi!
>>
>> I finally came up with something that I have been looking for. It
>> might be more suitable for Wicket 1.5 because it's not very compatible
>> (read: not very lean) with current wicket:
>>
>> Wicket Without Markup ;)
>>
>> Well, yes there is markup for each component, but when you lay them
>> out on the page, the markup is component-contained.
>> So coding an application feels like a breeze for the Java developer,
>> and the HTML developer can strictly stick to styling the (contained)
>> components themselves.
>>
>> Maybe I omitted something, but here comes the example. Let me know
>> what you think. Does it inspire any fresh ideas in you? Is this an old
>> idea? I recall listviews having been mentioned once as a solution for
>> producing markup-less code ... maybe I have re-invented the weel or
>> something.
>>
>> HomePage.html:
>> <html>
>> <body>
>> <strong>Wicket Quickstart Archetype Homepage</strong>
>> <form wicket:id="form">
>> <wicket:container wicket:id="root-content-id"></wicket:container>
>> </form>
>> </body>
>> </html>
>>
>>
>> HomePage.java:
>> public class HomePage extends WebPage {
>> /** */
>> private static final long serialVersionUID = 1L;
>> private final MarkupNoLongerRequiredContainer rootContainer;
>> private final MarkupNoLongerRequiredContainer row1;
>> private final MarkupNoLongerRequiredContainer row2;
>> private final MarkupNoLongerRequiredContainer row3;
>> private final Form<Void> form;
>>
>> /**
>> *
>> */
>> public HomePage() {
>> add(form = new Form<Void>("form"));
>> form.add(rootContainer = new
>> MarkupNoLongerRequiredContainer("root-content-id"));
>> {
>> rootContainer.add(row1 = new MarkupNoLongerRequiredContainer());
>> row1.add(new Label(GID, "Hello world"));
>> row1.add(0, new Label(GID, "<br/>").setEscapeModelStrings(false));
>> // Change row before
>> row1.add(0, new Label(GID, "<br/>").setEscapeModelStrings(false));
>> // Change row twice before
>> row1.add(new Label(GID, "<br/>").setEscapeModelStrings(false)); //
>> Change row once after
>> }
>> {
>> rootContainer.add(row2 = new MarkupNoLongerRequiredContainer());
>> row2.add(new Label(GID, "Type your name here:"));
>> row2.add(new InputField(new TextField<String>(GID, Model.of("..."))));
>> }
>> {
>> rootContainer.add(row3 = new MarkupNoLongerRequiredContainer());
>> row2.add(new Label(GID, "<br/>").setEscapeModelStrings(false)); //
>> Change row before
>> row2.add(new InputField(new Button(GID, Model.of("Clickme")) {
>> @Override
>> protected void onComponentTag(ComponentTag tag) {
>> tag.put("type", "button");
>> super.onComponentTag(tag);
>> }
>> }));
>> }
>> }
>> }
>>
>> InputField.html:
>> <wicket:panel>
>> <input wicket:id="generic-child-id"/>
>> </wicket:panel>
>>
>>
>> InputField.java:
>> public class InputField extends Panel {
>> /** */
>> private static final long serialVersionUID = 1L;
>>
>> public <InputFieldDataType, InputFieldType extends
>> FormComponent<InputFieldDataType>> InputField(InputFieldType
>> inputFieldType) {
>> super(MarkupNoLongerRequiredContainer.GID);
>> add(inputFieldType);
>> }
>> }
>>
>> MarkupNoLongerRequiredContainer.html:
>> <wicket:panel>
>> <wicket:container wicket:id="listview-id">
>> <wicket:container wicket:id="generic-child-id">
>> </wicket:container>
>> </wicket:container>
>> </wicket:panel>
>>
>>
>> MarkupNoLongerRequiredContainer.java:
>> public class MarkupNoLongerRequiredContainer extends Panel {
>> /** */
>> public static final String GID = "generic-child-id";
>>
>> /** */
>> private static final long serialVersionUID = 1L;
>>
>> private final List<Component> children = new ArrayList<Component>();
>>
>> public MarkupNoLongerRequiredContainer() {
>> this(GID);
>> }
>>
>> @Override
>> protected void onBeforeRender() {
>> super.onBeforeRender();
>> }
>>
>> /**
>> * @param id
>> */
>> public MarkupNoLongerRequiredContainer(String id) {
>> super(id);
>> super.add(new ListView<Component>("listview-id", children) {
>> /** */
>> private static final long serialVersionUID = 1L;
>>
>> @Override
>> protected void populateItem(ListItem<Component> listItem) {
>> Component component = listItem.getModelObject();
>> if (!component.getId().equals(GID)) {
>> throw new IllegalStateException("Currently handles only children
>> with id " + GID);
>> }
>> listItem.add(component);
>> }
>> });
>> }
>>
>> public boolean add(Component component) {
>> return children.add(component);
>> }
>>
>> public void add(int index, Component element) {
>> children.add(index, element);
>> }
>>
>> public boolean addAll(Collection<? extends Component> collection) {
>> return children.addAll(collection);
>> }
>>
>> public boolean addAll(int index, Collection<? extends Component>
>> collection) {
>> return children.addAll(index, collection);
>> }
>>
>> public void clear() {
>> children.clear();
>> }
>>
>> public boolean contains(Object o) {
>> return children.contains(o);
>> }
>>
>> public boolean containsAll(Collection<?> collection) {
>> return children.containsAll(collection);
>> }
>>
>> public int indexOf(Object o) {
>> return children.indexOf(o);
>> }
>>
>> public boolean isEmpty() {
>> return children.isEmpty();
>> }
>>
>> public int lastIndexOf(Object o) {
>> return children.lastIndexOf(o);
>> }
>>
>> public ListIterator<Component> listIterator() {
>> return children.listIterator();
>> }
>>
>> public ListIterator<Component> listIterator(int index) {
>> return children.listIterator(index);
>> }
>>
>> public boolean remove(Object o) {
>> return children.remove(o);
>> }
>>
>> public Component remove(int index) {
>> return children.remove(index);
>> }
>>
>> public boolean removeAll(Collection<?> collection) {
>> return children.removeAll(collection);
>> }
>>
>> public boolean retainAll(Collection<?> collection) {
>> return children.retainAll(collection);
>> }
>>
>> public Component set(int index, Component element) {
>> return children.set(index, element);
>> }
>>
>> public List<Component> subList(int fromIndex, int toIndex) {
>> return children.subList(fromIndex, toIndex);
>> }
>>
>> public Object[] toArray() {
>> return children.toArray();
>> }
>>
>> public <T> T[] toArray(T[] a) {
>> return children.toArray(a);
>> }
>> }
>>
>> **
>> Martin
>>
>> ---------------------------------------------------------------------
>> 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://old.nabble.com/Wicket-without-markup-tp27506286p27694080.html
> 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
Re: Wicket without markup
Posted by petar <pe...@yahoo.de>.
Hi Martin,
do you have any news on this subject? E.g. found that you reinvent the wheel
or started a project with this idea :-)?
Regards,
Peter.
MartinM wrote:
>
> Hi!
>
> I finally came up with something that I have been looking for. It
> might be more suitable for Wicket 1.5 because it's not very compatible
> (read: not very lean) with current wicket:
>
> Wicket Without Markup ;)
>
> Well, yes there is markup for each component, but when you lay them
> out on the page, the markup is component-contained.
> So coding an application feels like a breeze for the Java developer,
> and the HTML developer can strictly stick to styling the (contained)
> components themselves.
>
> Maybe I omitted something, but here comes the example. Let me know
> what you think. Does it inspire any fresh ideas in you? Is this an old
> idea? I recall listviews having been mentioned once as a solution for
> producing markup-less code ... maybe I have re-invented the weel or
> something.
>
> HomePage.html:
> <html>
> <body>
> <strong>Wicket Quickstart Archetype Homepage</strong>
> <form wicket:id="form">
> <wicket:container wicket:id="root-content-id"></wicket:container>
> </form>
> </body>
> </html>
>
>
> HomePage.java:
> public class HomePage extends WebPage {
> /** */
> private static final long serialVersionUID = 1L;
> private final MarkupNoLongerRequiredContainer rootContainer;
> private final MarkupNoLongerRequiredContainer row1;
> private final MarkupNoLongerRequiredContainer row2;
> private final MarkupNoLongerRequiredContainer row3;
> private final Form<Void> form;
>
> /**
> *
> */
> public HomePage() {
> add(form = new Form<Void>("form"));
> form.add(rootContainer = new
> MarkupNoLongerRequiredContainer("root-content-id"));
> {
> rootContainer.add(row1 = new MarkupNoLongerRequiredContainer());
> row1.add(new Label(GID, "Hello world"));
> row1.add(0, new Label(GID, "<br/>").setEscapeModelStrings(false));
> // Change row before
> row1.add(0, new Label(GID, "<br/>").setEscapeModelStrings(false));
> // Change row twice before
> row1.add(new Label(GID, "<br/>").setEscapeModelStrings(false)); //
> Change row once after
> }
> {
> rootContainer.add(row2 = new MarkupNoLongerRequiredContainer());
> row2.add(new Label(GID, "Type your name here:"));
> row2.add(new InputField(new TextField<String>(GID, Model.of("..."))));
> }
> {
> rootContainer.add(row3 = new MarkupNoLongerRequiredContainer());
> row2.add(new Label(GID, "<br/>").setEscapeModelStrings(false)); //
> Change row before
> row2.add(new InputField(new Button(GID, Model.of("Clickme")) {
> @Override
> protected void onComponentTag(ComponentTag tag) {
> tag.put("type", "button");
> super.onComponentTag(tag);
> }
> }));
> }
> }
> }
>
> InputField.html:
> <wicket:panel>
> <input wicket:id="generic-child-id"/>
> </wicket:panel>
>
>
> InputField.java:
> public class InputField extends Panel {
> /** */
> private static final long serialVersionUID = 1L;
>
> public <InputFieldDataType, InputFieldType extends
> FormComponent<InputFieldDataType>> InputField(InputFieldType
> inputFieldType) {
> super(MarkupNoLongerRequiredContainer.GID);
> add(inputFieldType);
> }
> }
>
> MarkupNoLongerRequiredContainer.html:
> <wicket:panel>
> <wicket:container wicket:id="listview-id">
> <wicket:container wicket:id="generic-child-id">
> </wicket:container>
> </wicket:container>
> </wicket:panel>
>
>
> MarkupNoLongerRequiredContainer.java:
> public class MarkupNoLongerRequiredContainer extends Panel {
> /** */
> public static final String GID = "generic-child-id";
>
> /** */
> private static final long serialVersionUID = 1L;
>
> private final List<Component> children = new ArrayList<Component>();
>
> public MarkupNoLongerRequiredContainer() {
> this(GID);
> }
>
> @Override
> protected void onBeforeRender() {
> super.onBeforeRender();
> }
>
> /**
> * @param id
> */
> public MarkupNoLongerRequiredContainer(String id) {
> super(id);
> super.add(new ListView<Component>("listview-id", children) {
> /** */
> private static final long serialVersionUID = 1L;
>
> @Override
> protected void populateItem(ListItem<Component> listItem) {
> Component component = listItem.getModelObject();
> if (!component.getId().equals(GID)) {
> throw new IllegalStateException("Currently handles only children
> with id " + GID);
> }
> listItem.add(component);
> }
> });
> }
>
> public boolean add(Component component) {
> return children.add(component);
> }
>
> public void add(int index, Component element) {
> children.add(index, element);
> }
>
> public boolean addAll(Collection<? extends Component> collection) {
> return children.addAll(collection);
> }
>
> public boolean addAll(int index, Collection<? extends Component>
> collection) {
> return children.addAll(index, collection);
> }
>
> public void clear() {
> children.clear();
> }
>
> public boolean contains(Object o) {
> return children.contains(o);
> }
>
> public boolean containsAll(Collection<?> collection) {
> return children.containsAll(collection);
> }
>
> public int indexOf(Object o) {
> return children.indexOf(o);
> }
>
> public boolean isEmpty() {
> return children.isEmpty();
> }
>
> public int lastIndexOf(Object o) {
> return children.lastIndexOf(o);
> }
>
> public ListIterator<Component> listIterator() {
> return children.listIterator();
> }
>
> public ListIterator<Component> listIterator(int index) {
> return children.listIterator(index);
> }
>
> public boolean remove(Object o) {
> return children.remove(o);
> }
>
> public Component remove(int index) {
> return children.remove(index);
> }
>
> public boolean removeAll(Collection<?> collection) {
> return children.removeAll(collection);
> }
>
> public boolean retainAll(Collection<?> collection) {
> return children.retainAll(collection);
> }
>
> public Component set(int index, Component element) {
> return children.set(index, element);
> }
>
> public List<Component> subList(int fromIndex, int toIndex) {
> return children.subList(fromIndex, toIndex);
> }
>
> public Object[] toArray() {
> return children.toArray();
> }
>
> public <T> T[] toArray(T[] a) {
> return children.toArray(a);
> }
> }
>
> **
> Martin
>
> ---------------------------------------------------------------------
> 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://old.nabble.com/Wicket-without-markup-tp27506286p27694080.html
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