Please send me the full class.
Here it is not working.
for e.g, I have a dynamic query like select * from tablename, I want to
display the table values into gridview. how?
thanks
edi
Newgro wrote:
>
> Hi *,
>
> i use wicket-1.2.6. I try to change the background-color of an gridtable
> item. But i dont get it to work. Is there a howto or doc for it? javadoc
> is not that detailed.
>
> My goal is to display a table with link as cell-content. If i click on the
> link the cell should be marked selected by changing the color.
>
> Maybe there is a better (simplier) way?
>
> Thanks for your help
>
> Per
>
> Here is my code (i removed some not required details, to shorten up the
> mail).
>
> package wicket.quickstart;
>
> import java.util.Date;
>
> import wicket.AttributeModifier;
> import wicket.Component;
> import wicket.PageParameters;
> import wicket.behavior.SimpleAttributeModifier;
> import wicket.extensions.markup.html.repeater.data.GridView;
> import wicket.extensions.markup.html.repeater.data.IDataProvider;
> import wicket.extensions.markup.html.repeater.data.ListDataProvider;
> import wicket.extensions.markup.html.repeater.refreshing.Item;
> import wicket.markup.html.basic.Label;
> import wicket.markup.html.link.Link;
> import wicket.model.IModel;
> import wicket.model.Model;
>
> public class SelectDay extends QuickStartPage {
> private static class HighlitableDataItem extends Item {
> private boolean highlite = true;
> private AttributeModifier modifier = null;
>
> public void toggleHighlite() {
> highlite = !highlite;
> }
>
> public HighlitableDataItem(String id, int index, IModel model) {
> super(id, index, model);
> modifier = new AttributeModifier("class", "selected", new Model() {
> public Object getObject(Component component) {
> if (highlite){
> return "selected";
> }
> return "deselected";
> }
> });
> add(modifier);
> }
> }
>
> public SelectDay(final PageParameters parameters) {
> List list = new ArrayList();
> list.add(1);
> list.add(2);
> list.add(3);
> IDataProvider dataProvider = new ListDataProvider(list);
> GridView gridView = new GridView("rows", dataProvider) {
>
> protected void populateItem(final Item item) {
> final Integer weekday = (Integer) item
> .getModelObject();
> Link link = new Link("toggleHighlite") {
>
> public void onClick() {
> System.out.println("onclick");
> HighlitableDataItem hitem = (HighlitableDataItem) item;
> hitem.toggleHighlite();
> }
> };
> link.add(new Label("linklabel", weekday));
> item.add(link);
> item.add(new Label("day", ""));
> }
>
> protected void populateEmptyItem(Item item) {
> throw new UnsupportedOperationException("Unexpected");
> }
>
> protected Item newItem(String id, int index, IModel model) {
> Item result = null;
> Object o = model.getObject(this);
> if (o instanceof Integer) {
> result = new HighlitableDataItem(id, index, model);
> result.add(new SimpleAttributeModifier("style",
> "background-color:#ffffff;"));
> } else {
> result = new Item(id, index, model);
> }
>
> return result;
> }
> };
>
> gridView.setRows(2);
> gridView.setColumns(2);
> add(gridView);
> }
> }
>
> SelectDay.html
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
> <title>Calendar</title>
> <link rel="stylesheet" href="buma.css" type="text/css" media="all" />
>
> </head>
>
> <body>
>
> <h1>QuickStart</h1>
>
> <p>Calendar</p>
> <div>
> <table class="calendar">
> <tbody>
> <tr wicket:id="rows">
> <td wicket:id="cols">
> #
>
> </td>
> </tr>
> </tbody>
> </table>
> </div>
> </body>
> </html>
>
> buma.css
>
>
> table.calendar {
> margin:auto;
> align: center;
> border-spacing: 3px;
> }
>
> table.calendar td {
> background: #FFBF00;
> text-align: center;
> color: #330000;
> border: 1px solid;
> border-color: #330000;
> padding: 1px 7px;
> margin: 3px;
> empty-cells: hide;
> }
>
> table.calendar .selected {
> background: #FFFFFF;
> text-align: center;
> color: #330000;
> border: 1px solid;
> border-color: #330000;
> padding: 1px 7px;
> margin: 3px;
> empty-cells: hide;
> }
>
> table.calendar .deselected {
> background: #FF00FF;
> text-align: center;
> color: #330000;
> border: 1px solid;
> border-color: #330000;
> padding: 1px 7px;
> margin: 3px;
> empty-cells: hide;
> }
>
> --
> Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
> Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/Howto-use-AttributeModifier-tf4391745.html#a12632332
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]