ok, and thank you, but why do i have to use this:
BookmarkablePageLink(item,"linkTo",link.getLinkTarget(),link.getParams());
and not using it instead like this:
BookmarkablePageLink(this,"linkTo",link.getLinkTarget(),link.getParams());
in
ListView(this, "tabList", tabList) {
> protected void populateItem(ListItem item) {
i mean, the markup is present in this not in item, isnt it??
Best Regards,
Korbinian
> -----Ursprüngliche Nachricht-----
> Von: Igor Vaynberg [mailto:[EMAIL PROTECTED]
> Gesendet: Samstag, 11. November 2006 18:56
> An: [email protected]
> Betreff: Re: Wicket 2.0 and Flexible Navigation List/ add problem
>
> you can do it any way you like.
>
> as with anything this refactor has tradeoffs. we decided to
> do it because with this refactor some things that were not
> possible before are now possible - but of course other things
> are now more difficult. the key is that we gained the ability
> to do something that was not possible before.
>
> simpleattributemodifier is now not needed. because of the
> refactor you have access to your markup immediately in the
> constructor, so instead of
>
> add(new AttributeModifier("class", "error")); you do
> getMarkupAttributes().put("class","error"));
>
> the parent confusion should also not be there. the pattern is
> like this
>
> where before you used to do A.add(new B("id")); you now do
> new B(A,"id");
>
> -igor
>
>
> On 11/11/06, Korbinian Bachl <[EMAIL PROTECTED]> wrote:
> >
> > Hi Igor,
> >
> > thank you for your reply. I changed it a bit more - i dont use a
> > linkFactory, but instead i use a new Link object, wich can
> be easily
> > added like this:
> >
> > tabList.add(new ShopLink("Description",Target.class,Pageparams));
> >
> > and then use it that way:
> > new ListView(this, "tabList", tabList) {
> > protected void populateItem(ListItem item) {
> > final ShopLink link = (ShopLink)
> > item.getModelObject();
> >
> > BookmarkablePageLink currentLink = new
> >
> BookmarkablePageLink(item,"linkTo",link.getLinkTarget(),link.g
> etParams());
> > currentLink.add(new
> SimpleAttributeModifier("id","aktiv")
> > {
> > public boolean isEnabled() {
> > return
> > paramsIn.getString("2","foo").equalsIgnoreCase(link.getLinkText());
> > }
> > });
> > new
> Label(currentLink,"linkName",link.getLinkText());
> >
> >
> > }
> > };
> >
> > I somehow like that new aproach in wicket 2.0 with the need to have
> > the MarkupContainer around, but some things are not clear
> to me yet...
> >
> > e.g: new SimpleAttributeModifier is marked as deprecated -
> what should
> > be used now? Javadoc is empty about this... the buildate
> (Snapshot) is
> > today 13:00 MEZ;
> >
> > also, its a bit confusing as i sometime get lost in the
> "stage" where
> > to put
> > what: eg: its harder now as you have to follow the strict path e.g:
> > BasePage->Component->Component wherease before you didnt take care
> > BasePage->Component->about
> > that..
> > (i had some troubel till i figured out to put the
> > BookMarkablePageLink(item,..) instead of (this,..) - still
> dont know
> > why its item and not this...)
> >
> > Best Regards,
> >
> > Korbinian
> >
> >
> >
> >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Igor Vaynberg [mailto:[EMAIL PROTECTED]
> > > Gesendet: Freitag, 10. November 2006 19:53
> > > An: [email protected]
> > > Betreff: Re: Wicket 2.0 and Flexible Navigation List/ add problem
> > >
> > > add(new ListView("navList", navList) {
> > > protected void populateItem(ListItem item) {
> > > ILinkFactory factory=item.getModelObject();
> > > factory.newLink(item, "id");
> > > }
> > > });
> > >
> > >
> > > -igor
> > >
> > >
> > > On 11/10/06, Korbinian Bachl <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Hi Igor,
> > > >
> > > > thanks for your reply. I understand that i should do it
> using an
> > > > interface and not expose the wicket:id's.
> > > >
> > > > However, even if i pass it in there (navlist now as
> navList<ILink>):
> > > >
> > > > > add(new ListView("navList", navList) {
> > > > > protected void populateItem(ListItem item) {
> > > > > BookmarkablePageLink link =
> > > (BookmarkablePageLink)
> > > > > item.getModelObject();
> > > > > item.add(link);
> > > > > }
> > > > > });
> > > >
> > > >
> > > > how can i add it to it ? - i dont understand how i use it
> > > there - even
> > > > is its IList i would add it, but now i need its parent
> Component...
> > > >
> > > >
> > > > Regards,
> > > >
> > > > Korbinian
> > > >
> > > >
> > > > > -----Ursprüngliche Nachricht-----
> > > > > Von: Igor Vaynberg [mailto:[EMAIL PROTECTED]
> > > > > Gesendet: Freitag, 10. November 2006 17:43
> > > > > An: [email protected]
> > > > > Betreff: Re: Wicket 2.0 and Flexible Navigation List/ add
> > > > > problem
> > > > >
> > > > > first of all i wouldnt pass components around in a list.
> > > > >
> > > > > there are a couple of ways to do that
> > > > >
> > > > > the easist would probably be to have something like this:
> > > > >
> > > > > interface ILinkFactory { Link newLink(Component parent,
> > > String id);
> > > > > }
> > > > >
> > > > > then instead of List<BookmarkablePageLink> you pass in
> > > > > List<ILinkFactory>.
> > > > > notice this is also better because now the code that
> > > generates links
> > > > > doesnt have a fuzzy contract about link's id with the
> code that
> > > > > renders it.
> > > > >
> > > > > -igor
> > > > >
> > > > >
> > > > > On 11/10/06, Korbinian Bachl <[EMAIL PROTECTED]> wrote:
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > i tried to convert my current skeleton to wicket 2.0,
> > > but stumbled
> > > > > > into a problem i cant solve so far:
> > > > > >
> > > > > > My base:
> > > > > >
> > > > > > I have a LinkPanel that creates a List containing
> > > > > Navigationallinks in
> > > > > > a MasterPage (here BasePage extending WebPage) and uses a
> > > > > > getNavList(PageParameters paramsIn) function to resolve
> > > > > this from the
> > > > > > current page (wich is overriden by the extending page then)
> > > > > >
> > > > > > The Panel itself:
> > > > > >
> > > > > > HTML:
> > > > > > <wicket:panel>
> > > > > > <h4 wicket:id="headline">Linklist</h4>
> > > > > > <ul>
> > > > > > <li
> wicket:id="navList"><a href="#"
> > > > > > wicket:id="linkTo"><span
> > > wicket:id="linkName">Link</span></a></li>
> > > > > >
> > > > > > </ul>
> > > > > > </wicket:panel>
> > > > > >
> > > > > > Java:
> > > > > > public class NavigationLinks extends Panel{
> > > > > >
> > > > > > /** Creates a new instance of NavigationLinks */
> > > > > > public NavigationLinks(String id, final List navList) {
> > > > > > super(id);
> > > > > > add(new Label("headline","Kopzeile"));
> > > > > > add(new ListView("navList", navList) {
> > > > > > protected void populateItem(ListItem item) {
> > > > > > BookmarkablePageLink link =
> > > (BookmarkablePageLink)
> > > > > > item.getModelObject();
> > > > > > item.add(link);
> > > > > > }
> > > > > > });
> > > > > >
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > and its feed like this:
> > > > > >
> > > > > > in constructor of BasePage:
> > > > > > NavigationLinks nl = new
> > > > > > NavigationLinks("NavigationLinks",getNavList(paramIn));
> > > > > > add(nl);
> > > > > >
> > > > > > with public List getNavList(PageParameters paramIn)
> > > > > > {
> > > > > > PageParameters params =
> > > > > > ((SpecialSession)getSession()).getNewGlobalParams();
> > > > > > List navList = new ArrayList();
> > > > > > params.add(Integer.toString(params.size()),"FOO");
> > > > > > params.add(Integer.toString(params.size()),"Bar");
> > > > > > navList.add(new
> > > > > > BookmarkablePageLink("linkTo",Katalog.class,
> > > > > > params).add(new Label("linkName","Foo Bar")));
> > > > > > [...]
> > > > > > return navList;
> > > > > > }
> > > > > >
> > > > > > i know i need to put the superclass-ref into the panel
> > > > > using this and
> > > > > > a corresponding var, but what i dont understand is
> how i can
> > > > > > solve this
> > > > > > part:
> > > > > >
> > > > > > add(new ListView("navList", navList) {
> > > > > > protected void populateItem(ListItem item) {
> > > > > > BookmarkablePageLink link =
> > > (BookmarkablePageLink)
> > > > > > item.getModelObject();
> > > > > > item.add(link);
> > > > > > }
> > > > > > });
> > > > > >
> > > > > > ok, the add is gone, so it would be new ListView(this,
> > > "navList",
> > > > > > navList) {
> > > > > > protected void populateItem(ListItem item) {
> > > > > > BookmarkablePageLink link =
> > > (BookmarkablePageLink)
> > > > > > item.getModelObject();
> > > > > > item.add(link);
> > > > > > }
> > > > > > };
> > > > > > but how can I fix this part:
> > > > > > BookmarkablePageLink link = (BookmarkablePageLink)
> > > > > item.getModelObject();
> > > > > > item.add(link); as i cant "add" it
> anymore...
> > > > > > ?
> > > > > >
> > > > > > or I am on a Antipattern here? My need is that i have a
> > > > > Place where i
> > > > > > need to put BookMarkablePageLinks dynamically to...
> > > > > >
> > > > > > Best Regards,
> > > > > >
> > > > > > Korbinain
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>