Re: Is this right? Seems at odds with wicket philosophy

2008-08-14 Thread Wayne Pope
Hey Igor,

thanks very much again for your help.

it is amazing how you can fully understand the wicket philosophy after
only one day using it :)
LOL yes, I just meant from how I had understood it - which obviously is not
great at the moment. We all start from somewhere! :-)


this is simply item.add(new
WebMarkupContainer(comment).setOutputMarkupId(true));
wicket already has facilities for outputting unique markup ids

Ok thanks for that. Is there anyway to 'namespace' this? . My component is
displayed in 2 different areas of the same page (using different model
behind), therefore I need to assign either the component id plus an index to
the markup id to make it unique in the document. (I'd actually cut that out
of the example code I was using here). I suppose I can componentize it?

Does anyone know if there are any architecture diagrams/flows of how things
happenings in Wicket? I read the 'Wicket In Action' book pre-lease which
gave a great introduction for me, however there's only so much can be
covered. I'd like to understand the exact flows and what options there are,
or would you suggest I just get the code and step through it?

Thanks
Wayne


On Wed, Aug 13, 2008 at 7:03 PM, Igor Vaynberg [EMAIL PROTECTED]wrote:

 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]




Re: Is this right? Seems at odds with wicket philosophy

2008-08-14 Thread Matthijs Wensveen
Why not create a wicket components for the comment div and the 
makecomment link. Then in the onClick override of the makecomment link 
you can set the visibility of the comment component. This does require a 
roundtrip to the server, but is IMO more the wicket-way (tm).


Matthijs

Wayne Pope 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. Let me explain:

I have a very simple news feed that I want to be able to comment on, this
textarea should only be visible once I click on a link.

the markup
div wicket:id=newsItems
  strong wicket:id=title/
  p wicket:id=description/
  div id=comment style=display:none 
   textareatextarea
  div
  a href=# wicket:id=makecomment
onclick=getElementById(comment').style.display='';return false;Make
comment/a
/div

As there are lots of news items, I need to assign a unique id (markup id,
not wicket id) to the div element and the corresponding onclick attribute
in the anchor.

So in the java I have to do it this way:
ListView items = new ListView(newsItems,feed) {
@Override
protected void populateItem(ListItem item) {
FeedItem news = (FeedItem) item.getModelObject();
item.add(new Label(title, new
PropertyModel(news,title)));
item.add(new Label(description, new
PropertyModel(news,description)));

final int index = item.getIndex();
item.add(new WebMarkupContainer(makecomment) {
protected void onComponentTag(ComponentTag tag) {

tag.getAttributes().put(onclick,getElementById('comment+index+').style.display='';return
false;); }
});


item.add(new WebMarkupContainer(comment) {
protected void onComponentTag(ComponentTag tag) {
tag.getAttributes().put(id,comment+index); }
});


}
};

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

  



--
Matthijs Wensveen
Func. Internet Integration
W http://www.func.nl
T +31 20 423
F +31 20 4223500 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Is this right? Seems at odds with wicket philosophy

2008-08-14 Thread Igor Vaynberg
On Thu, Aug 14, 2008 at 4:03 AM, Wayne Pope
[EMAIL PROTECTED] wrote:
 Ok thanks for that. Is there anyway to 'namespace' this? . My component is
 displayed in 2 different areas of the same page (using different model
 behind), therefore I need to assign either the component id plus an index to
 the markup id to make it unique in the document. (I'd actually cut that out
 of the example code I was using here). I suppose I can componentize it?

getmarkupid() always generates a unique id, even across instances of
the same component class.

-igor



 Does anyone know if there are any architecture diagrams/flows of how things
 happenings in Wicket? I read the 'Wicket In Action' book pre-lease which
 gave a great introduction for me, however there's only so much can be
 covered. I'd like to understand the exact flows and what options there are,
 or would you suggest I just get the code and step through it?

 Thanks
 Wayne


 On Wed, Aug 13, 2008 at 7:03 PM, Igor Vaynberg [EMAIL PROTECTED]wrote:

 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]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]