On Wed, Aug 13, 2008 at 9:50 AM, Wayne Pope
<[EMAIL PROTECTED]> wrote:
> Ok,
>
> so I'm new to this, however things have been progression ok for my first day
> with Wicket.
> However it seems to me that I must be doing HTML markup manipulation in java
> when the manipulation only concerns the view and not the data behind it.
> This seems at odds with wicket philosophy.
it is amazing how you can fully understand the wicket philosophy after
only one day using it :) anyways, what you are doing is not markup
manipulation, you are outputting a dynamic value attribute which is
quiet logical to do from code...
> item.add(new Label("title", new
> PropertyModel(news,"title")));
proper way to do this is to chain the models:
item.add(new label("title", new propertymodel(item.getmodel(), "title")))
> item.add(new WebMarkupContainer("comment") {
> protected void onComponentTag(ComponentTag tag) {
> tag.getAttributes().put("id","comment"+index); }
> });
this is simply item.add(new
WebMarkupContainer("comment").setOutputMarkupId(true));
wicket already has facilities for outputting unique markup ids
> item.add(new WebMarkupContainer("makecomment") {
> protected void onComponentTag(ComponentTag tag) {
> tag.getAttributes().put("onclick","getElementById('comment"+index+"').style.display='';return
> false;"); }
> });
componentize this:
class javascriptshowlink extends webmarkupcontainer {
private final component target;
// constructor left to your imagination
protected void oncomponenttag(tag) {
tag.put("onclick",
"getelementbyid('"+target.getmarkupid();+"').style.display='';return
false;");
// there is nothing wrong with doing this, it is a dynamic string
generated via code
}
then just item.add(new javascriptshowlink("show", commentContainer);
-igor
>
>
>
>
> }
> };
>
> add(items);
>
>
> Ok so that code is just to demonstrate what I mean. The point is I need to
> manipulate the attributes of elements, just so I can setup some javascript
> stuff. Is there no better way of just doing this in the markup or some form
> of wicket:tag that can insert the current list item index?
>
> thanks
> Wayne
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]