You are aware that in valid HTML the ID of an element should be
unique?

No, I was not aware of this issue, but already wondered, why IDEA complained. I've changed all id's to class'es and now it should be HTML conform, right?

--
Cheers,
Tom


Martijn Dashorst schrieb:
Tom,

You are aware that in valid HTML the ID of an element should be
unique? I think that in this case you really mean to use a class.

<div wicket:id="news" class="newsEntryHot">
    <div wicket:id="date" class="newsDate">xxx</div>
    <div wicket:id="headline" class="newsHeadline">xxx</div>
    <div wicket:id="message" class="newsContent">xxx</div>
</div>

And probably even better:

<div wicketid="news" class="news">
    ...
</div>

IModel HOTMODEL = new Model("hot");
IModel NOTMODEL = new Model("");
protected void populateItem(ListItem item) {
    item.add(new AttributeModifier("class", true, hot ? HOTMODEL : NOTMODEL) {
        protected String newValue(final String currentValue, final
String replacementValue)
        {
            return currentValue + " " + replacementValue;
        }
    });
    // etc.
}

this will generate the following div for a hot item, and the next for
a not so hot item:

<div class="news hot">etc</div>
<div class="news">etc</div>

This gives you more power in your CSS to use it to its full potential.

Martijn

On 2/12/06, Tom S. <[EMAIL PROTECTED]> wrote:
Eelco, thank you very much. I've stripped the redundant span-tags and used
it like that (for those who are interested):

   <div wicket:id="news" id="newsEntryHot">
     <div id="newsDate" wicket:id="date">06-01-05</div>
     <div id="newsHeadline" wicket:id="headline">App released</div>
     <div id="newsContent" wicket:id="message">Bla bla</div>
   </div>

and

  public class NewsListView extends ListView {
    ...

    private final Model hotModel = new Model("newsEntryHot");
    private final Model normalModel = new Model("newsEntryNormal");

    public NewsListView(List newsEntries) {
      super("news", newsEntries);
    }

    protected void populateItem(ListItem item) {
      final NewsItem news = (NewsItem)item.getModelObject();
      item.add(new AttributeModifier("id", true,
                                     news.isHot() ? hotModel : normalModel));
      item.add(new Label("date", DATE_FORMAT.format(news.getDate())));
      item.add(new Label("headline", news.getHeadline()));
      item.add(new Label("message", news.getMessage()));
    }
  }

--
Cheers,
Tom


Eelco Hillenius schrieb:
or in case you use old skool AttributeModifier

   outerDiv.add(new AttributeModifier("id", true, new Model(id)));

Eelco

On 2/12/06, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
Yeah, AttributeModifier is the right way to go. Especially in your
case, because you probably want to do something like this:

Your listview:

...
protected abstract void populateItem(final ListItem item) {
  NewsItem newsItem = (NewsItem)item.getModelObject();
  String id = (newsItem.isCool()) ? "newsEntryHot" : "newsEntryBoring";
  WebMarkupContainer outerDiv = new WebMarkupContainer("outer");
  outerDiv.add(new SimpleAttributeModifier("id", id));
  item.add(outerDiv);
  ... // etc
}

Eelco

On 2/12/06, Tom S. <[EMAIL PROTECTED]> wrote:
Hi all,

I'm new to Wicket and so far I like it. :)

I want to show a small news-list on a page and use a ListView for that. In
the html-page it looks like this:

  <span wicket:id="news">
    <div id="newsEntryHot">
      <div id="newsDate">
        <span wicket:id="date">06-01-05</span>
      </div>
      <div id="newsHeadline">
         <span wicket:id="headline">App released</span>
       </div>
       <div id="newsContent">
         <span wicket:id="message">Bla bla</span>
       </div>
     </div>
  </span>

We have defined different looks for "hot" and "normal" news. Hot news should
have the outer div with id="newsEntryHot", normal ones with a different id.
The information is locally available as a boolean property of the NewsEntry.

How do I change the id-parameter? I've found the AttributeModifier class,
but have not clue, whether it is the right thing and/or how to use it, esp.
the related model.

Thanks in advance,
Tom


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=k&kid3432&bid#0486&dat1642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user



--
Living a wicket life...

Martijn Dashorst - http://www.jroller.com/page/dashorst

Wicket 1.1.1 is out: http://wicket.sourceforge.net/wicket-1.1


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=k&kid3432&bid#0486&dat1642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to