Re: Model never called

2008-11-19 Thread Michael Sparer

you should rather add an IModel to the link e.g. new Link(foobar, myModel);
than letting a component implement IModel. the way you did it, the model is
never recognised as a model, as it wasn't set as a model of a component.
hope that makes sense

regards,
Michael


Leucht, Axel wrote:
 
 Hi,
 
 I do have a link class which should render different icons when clicked. 
 
 So I decided to implement IModel and return different icons depending on
 the state of the object. But to my surprise getObject() never get called!
 
 Does anyone give me a clue where to look next or give me a hint as to how
 to render the object with a different icon?
 
 The object is used in a 10x10 board game where a player can shoot at
 different squares which are rendered as links in the output. The board is
 constructed as:
   ListView listview = new ListView(rows, list) {
   private static final long serialVersionUID = 1L;
 
   protected void populateItem(ListItem item) {
   Row row = (Row) item.getModelObject();
   final Square[] squares = new Square[10];
   for (int col=0; col10; col++) {
   squares[col] = row.getCells(col);
   }
   Square square = row.getCells(0);
   item.add(new Label(row,new 
 Model(square.getRow(;
   for (int col=0; col10; col++) {
   final Square aSquare = 
 row.getCells(col);
   item.add(aSquare);
   }
   }
   };
 And the Square-Object is:
   public class Square extends Link implements IModel {
   @Override
   public void onClick() {
   System.out.println(Click: + ident);
   }
 
   @Override
   public Object getObject() {
   System.out.println(GetObject);
   if (someState)
   return icon1;
   return icon2;
 
   }
   }
 
 /Axel
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 


-
Michael Sparer
http://talk-on-tech.blogspot.com
-- 
View this message in context: 
http://www.nabble.com/Model-never-called-tp20577931p20578051.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



AW: Model never called

2008-11-19 Thread Leucht, Axel
Nope, doesn't work either.

I've created a new class MySquare implementing IModel but the getObject() never 
get called either.

I'm stumped.

In populateItem I do:
for (int col=0; col10; col++) {
MySquare mySquare = new MySquare();
Link link = new Link(cols+col, mySquare) {
public void onClick() {
System.out.println(clicked);
}
};
link.add(new Image(icon+col,Square.emptyResource));
item.add(link);

/Axel


-Ursprüngliche Nachricht-
Von: Michael Sparer [mailto:[EMAIL PROTECTED]
Gesendet: Mittwoch, 19. November 2008 12:37
An: users@wicket.apache.org
Betreff: Re: Model never called



you should rather add an IModel to the link e.g. new 
Link(foobar, myModel);
than letting a component implement IModel. the way you did 
it, the model is
never recognised as a model, as it wasn't set as a model of a 
component.
hope that makes sense

regards,
Michael


Leucht, Axel wrote:
 
 Hi,
 
 I do have a link class which should render different icons 
when clicked. 
 
 So I decided to implement IModel and return different icons 
depending on
 the state of the object. But to my surprise getObject() 
never get called!
 
 Does anyone give me a clue where to look next or give me a 
hint as to how
 to render the object with a different icon?
 
 The object is used in a 10x10 board game where a player can 
shoot at
 different squares which are rendered as links in the 
output. The board is
 constructed as:
 ListView listview = new ListView(rows, list) {
 private static final long serialVersionUID = 1L;
 
 protected void populateItem(ListItem item) {
 Row row = (Row) item.getModelObject();
 final Square[] squares = new Square[10];
 for (int col=0; col10; col++) {
 squares[col] = 
row.getCells(col);
 }
 Square square = row.getCells(0);
 item.add(new Label(row,new 
Model(square.getRow(;
 for (int col=0; col10; col++) {
 final Square aSquare = 
row.getCells(col);
 item.add(aSquare);
 }
 }
 };
 And the Square-Object is:
 public class Square extends Link implements IModel {
 @Override
 public void onClick() {
 System.out.println(Click: + ident);
 }
 
 @Override
 public Object getObject() {
 System.out.println(GetObject);
 if (someState)
 return icon1;
 return icon2;
 
 }
 }
 
 /Axel
 
 
-
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 


-
Michael Sparer
http://talk-on-tech.blogspot.com
-- 
View this message in context: 
http://www.nabble.com/Model-never-called-tp20577931p20578051.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
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]



Model never called

2008-11-19 Thread Leucht, Axel
Hi,

I do have a link class which should render different icons when clicked. 

So I decided to implement IModel and return different icons depending on the 
state of the object. But to my surprise getObject() never get called!

Does anyone give me a clue where to look next or give me a hint as to how to 
render the object with a different icon?

The object is used in a 10x10 board game where a player can shoot at 
different squares which are rendered as links in the output. The board is 
constructed as:
ListView listview = new ListView(rows, list) {
private static final long serialVersionUID = 1L;

protected void populateItem(ListItem item) {
Row row = (Row) item.getModelObject();
final Square[] squares = new Square[10];
for (int col=0; col10; col++) {
squares[col] = row.getCells(col);
}
Square square = row.getCells(0);
item.add(new Label(row,new 
Model(square.getRow(;
for (int col=0; col10; col++) {
final Square aSquare = 
row.getCells(col);
item.add(aSquare);
}
}
};
And the Square-Object is:
public class Square extends Link implements IModel {
@Override
public void onClick() {
System.out.println(Click: + ident);
}

@Override
public Object getObject() {
System.out.println(GetObject);
if (someState)
return icon1;
return icon2;

}
}

/Axel

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



RES: Model never called

2008-11-19 Thread Bruno Cesar Borges
I couldn't understand the part about the icon, but what I know is that 
'getObject()' will *never* be called until you set the Square object into 
itself as the model:

public Square() {
   setModel(this);
}

Regards,
Bruno

-Mensagem original-
De: Leucht, Axel [mailto:[EMAIL PROTECTED]
Enviada em: quarta-feira, 19 de novembro de 2008 09:28
Para: [EMAIL PROTECTED] Apache. Org (E-Mail)
Assunto: Model never called


Hi,

I do have a link class which should render different icons when clicked. 

So I decided to implement IModel and return different icons depending on the 
state of the object. But to my surprise getObject() never get called!

Does anyone give me a clue where to look next or give me a hint as to how to 
render the object with a different icon?

The object is used in a 10x10 board game where a player can shoot at 
different squares which are rendered as links in the output. The board is 
constructed as:
ListView listview = new ListView(rows, list) {
private static final long serialVersionUID = 1L;

protected void populateItem(ListItem item) {
Row row = (Row) item.getModelObject();
final Square[] squares = new Square[10];
for (int col=0; col10; col++) {
squares[col] = row.getCells(col);
}
Square square = row.getCells(0);
item.add(new Label(row,new 
Model(square.getRow(;
for (int col=0; col10; col++) {
final Square aSquare = 
row.getCells(col);
item.add(aSquare);
}
}
};
And the Square-Object is:
public class Square extends Link implements IModel {
@Override
public void onClick() {
System.out.println(Click: + ident);
}

@Override
public Object getObject() {
System.out.println(GetObject);
if (someState)
return icon1;
return icon2;

}
}

/Axel

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

***
Atenção: Esta mensagem foi enviada para uso exclusivo do(s) destinatários(s) 
acima identificado(s),
podendo conter informações e/ou documentos confidencias/privilegiados e seu 
sigilo é protegido por 
lei. Caso você tenha recebido por engano, por favor, informe o remetente e 
apague-a de seu sistema.
Notificamos que é proibido por lei a sua retenção, disseminação, distribuição, 
cópia ou uso sem 
expressa autorização do remetente. Opiniões pessoais do remetente não refletem, 
necessariamente, 
o ponto de vista da CETIP, o qual é divulgado somente por pessoas autorizadas.


Warning: This message was sent for exclusive use of the addressees above 
identified, possibly 
containing information and or privileged/confidential documents whose content 
is protected by law. 
In case you have mistakenly received it, please notify the sender and delete it 
from your system. 
Be noticed that the law forbids the retention, dissemination, distribution, 
copy or use without 
express authorization from the sender. Personal opinions of the sender do not 
necessarily reflect 
CETIP's point of view, which is only divulged by authorized personnel.
***


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



Re: Model never called

2008-11-19 Thread Jeremy Thomerson
A model is only in a link as a convenience for YOU to use.  It's not used by
default - what about a link needs a model?  Rather, it's for something like:

new Link(deleteUser, modelContainingUser) {
  onClick() {
userDAO.delete(getModelObject());
  }
}

It's for YOU to use.  For instance, let's make a simpler example supposing
that you were changing the state of a label (rather than an image) with your
link.  You could do something like this:

ModelString model = new ModelString(default value);
Link link = new Link(link, model) {
public void onClick() {
System.out.println(clicked);
setModelObject(I've been clicked);
}
}
link.add(new Label(label, model));
item.add(link);

The Label calls getObject() on its model because it needs data to print.
Since you share the model between the two, changing it in the link will
change it in the label.

Now, back to your image example - images use image resources, not models,
and I don't think this will work like you have it drawn.  You need to
experiment with image resources for that.  Hopefully this gives you a better
understanding of models, though.


-- 
Jeremy Thomerson
http://www.wickettraining.com

On Wed, Nov 19, 2008 at 6:57 AM, Leucht, Axel [EMAIL PROTECTED] wrote:

 Nope, doesn't work either.

 I've created a new class MySquare implementing IModel but the getObject()
 never get called either.

 I'm stumped.

 In populateItem I do:
 for (int col=0; col10; col++) {
MySquare mySquare = new MySquare();
Link link = new Link(cols+col, mySquare) {
public void onClick() {
System.out.println(clicked);
}
 };
 link.add(new Image(icon+col,Square.emptyResource));
 item.add(link);

 /Axel


 -Ursprüngliche Nachricht-
 Von: Michael Sparer [mailto:[EMAIL PROTECTED]
 Gesendet: Mittwoch, 19. November 2008 12:37
 An: users@wicket.apache.org
 Betreff: Re: Model never called
  
 
 
 you should rather add an IModel to the link e.g. new
 Link(foobar, myModel);
 than letting a component implement IModel. the way you did
 it, the model is
 never recognised as a model, as it wasn't set as a model of a
 component.
 hope that makes sense
 
 regards,
 Michael
 
 
 Leucht, Axel wrote:
 
  Hi,
 
  I do have a link class which should render different icons
 when clicked.
 
  So I decided to implement IModel and return different icons
 depending on
  the state of the object. But to my surprise getObject()
 never get called!
 
  Does anyone give me a clue where to look next or give me a
 hint as to how
  to render the object with a different icon?
 
  The object is used in a 10x10 board game where a player can
 shoot at
  different squares which are rendered as links in the
 output. The board is
  constructed as:
  ListView listview = new ListView(rows, list) {
  private static final long serialVersionUID = 1L;
 
  protected void populateItem(ListItem item) {
  Row row = (Row) item.getModelObject();
  final Square[] squares = new Square[10];
  for (int col=0; col10; col++) {
  squares[col] =
 row.getCells(col);
  }
  Square square = row.getCells(0);
  item.add(new Label(row,new
 Model(square.getRow(;
  for (int col=0; col10; col++) {
  final Square aSquare =
 row.getCells(col);
  item.add(aSquare);
  }
  }
  };
  And the Square-Object is:
  public class Square extends Link implements IModel {
  @Override
  public void onClick() {
  System.out.println(Click: + ident);
  }
 
  @Override
  public Object getObject() {
  System.out.println(GetObject);
  if (someState)
  return icon1;
  return icon2;
 
  }
  }
 
  /Axel
 
 
 -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 
 -
 Michael Sparer
 http://talk-on-tech.blogspot.com
 --
 View this message in context:
 http://www.nabble.com/Model-never-called-tp20577931p20578051.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 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]