Re: attribute modifier on onclick

2008-11-04 Thread Michael Sparer

show us some code

miro wrote:
 
 I have a linkthis contains a label , now I want  to change the style
 of the label   whenever user clicks on the link ,  to do this   I override 
 the method onClick()  in  link component  I am retrieving the label  and
 adding  simpleattributemodifier to the label , but there is no change ,
 when I see the generated html it does not include  the added style  , can
 I change the style of a component in  any of the   events of a component ?
 


-
Michael Sparer
http://talk-on-tech.blogspot.com
-- 
View this message in context: 
http://www.nabble.com/attribute-modifier-on-onclick-tp20310246p20318681.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]



Re: attribute modifier on onclick

2008-11-04 Thread miro

I found the problem its because of   ListView   setReuseItems(boolean
reuseItems) .
by default it is  false  setting it to true will not create new instances of
my ListItems.  


Alex Objelean wrote:
 
 You probably want to use AjaxLink and when the link is clicked - add to
 the target the link itself, in order to see the change.
 
 
 miro wrote:
 
 upon debugging i foundthe constructor MyLink()  was getting called
 afteronClick() so any changes I make in onClick to components
 behaviour will get washed away because its adding the componentsagain
 , to better understand  what happens when a link is clicked ?  the
 component is created again ?
  
 
 here is the code 
 code
  PageableListView   batchesListView= new 
 PageableListView(batches,batches,10){
  
  /**
   * 
   */
  private static final long serialVersionUID = 1L;
 
  @Override
  protected void populateItem(ListItem item) {
  final BatcheModel   
 batcheModel=(BatcheModel)item.getModelObject();
  
  
  class MyLink extends Link  {
  public MyLink() {
  super(batch, new 
 Model(batcheModel));
  add(new 
 Label(name,batcheModel.getName()));
  add(new Label(date, new 
 Date().toString()));
  }
  @Override
  public void onClick() {
  final BatcheModel   
 batcheModel=(BatcheModel)getModelObject();
  AuditsModel auditsModel=null;
  
 if(batcheModel.getName().equals(test1)){
  auditsModel= new 
 AuditsModel(test1,test1,test1);
  }
  
 if(batcheModel.getName().equals(test2)){
  auditsModel= new 
 AuditsModel(test2,test2,test2);
  }
  
 if(batcheModel.getName().equals(test3)){
  auditsModel= new 
 AuditsModel(test3,test3,test3);
  }
  ListAuditsModel audits= new 
 ArrayListAuditsModel();
  audits.add(auditsModel);
  PageableListView 
 pageableListView=   (PageableListView)
 AuditSelectionPage.this.get(audits);
  pageableListView.setModel(new 
 Model((Serializable)audits));
  Label  label=(Label)get(name);
  get(name).add(new 
 SimpleAttributeModifier(style,
 color:blue;));
  get(date).add(new 
 SimpleAttributeModifier(style,
 color:blue;));
  }
  }
  
  item.add(new MyLink());
 
 /code
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/attribute-modifier-on-onclick-tp20310246p20324340.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]



Re: attribute modifier on onclick

2008-11-04 Thread Alex Objelean

You probably want to use AjaxLink and when the link is clicked - add to the
target the link itself, in order to see the change.


miro wrote:
 
 upon debugging i foundthe constructor MyLink()  was getting called
 afteronClick() so any changes I make in onClick to components
 behaviour will get washed away because its adding the componentsagain
 , to better understand  what happens when a link is clicked ?  the
 component is created again ?
  
 
 here is the code 
 code
   PageableListView   batchesListView= new 
 PageableListView(batches,batches,10){
   
   /**
* 
*/
   private static final long serialVersionUID = 1L;
 
   @Override
   protected void populateItem(ListItem item) {
   final BatcheModel   
 batcheModel=(BatcheModel)item.getModelObject();
   
   
   class MyLink extends Link  {
   public MyLink() {
   super(batch, new 
 Model(batcheModel));
   add(new 
 Label(name,batcheModel.getName()));
   add(new Label(date, new 
 Date().toString()));
   }
   @Override
   public void onClick() {
   final BatcheModel   
 batcheModel=(BatcheModel)getModelObject();
   AuditsModel auditsModel=null;
   
 if(batcheModel.getName().equals(test1)){
   auditsModel= new 
 AuditsModel(test1,test1,test1);
   }
   
 if(batcheModel.getName().equals(test2)){
   auditsModel= new 
 AuditsModel(test2,test2,test2);
   }
   
 if(batcheModel.getName().equals(test3)){
   auditsModel= new 
 AuditsModel(test3,test3,test3);
   }
   ListAuditsModel audits= new 
 ArrayListAuditsModel();
   audits.add(auditsModel);
   PageableListView 
 pageableListView=   (PageableListView)
 AuditSelectionPage.this.get(audits);
   pageableListView.setModel(new 
 Model((Serializable)audits));
   Label  label=(Label)get(name);
   get(name).add(new 
 SimpleAttributeModifier(style,
 color:blue;));
   get(date).add(new 
 SimpleAttributeModifier(style,
 color:blue;));
   }
   }
   
   item.add(new MyLink());
 
 /code
 
 

-- 
View this message in context: 
http://www.nabble.com/attribute-modifier-on-onclick-tp20310246p20323946.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]



Re: attribute modifier on onclick

2008-11-04 Thread miro

upon debugging i foundthe constructor MyLink()  was getting called after   
onClick() so any changes I make in onClick to components behaviour will get
washed away because its adding the componentsagain , to better
understand  what happens when a link is clicked ?  the component is created
again ?
 

here is the code 
code
PageableListView   batchesListView= new 
PageableListView(batches,batches,10){

/**
 * 
 */
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(ListItem item) {
final BatcheModel   
batcheModel=(BatcheModel)item.getModelObject();


class MyLink extends Link  {
public MyLink() {
super(batch, new 
Model(batcheModel));
add(new 
Label(name,batcheModel.getName()));
add(new Label(date, new 
Date().toString()));
}
@Override
public void onClick() {
final BatcheModel   
batcheModel=(BatcheModel)getModelObject();
AuditsModel auditsModel=null;

if(batcheModel.getName().equals(test1)){
auditsModel= new 
AuditsModel(test1,test1,test1);
}

if(batcheModel.getName().equals(test2)){
auditsModel= new 
AuditsModel(test2,test2,test2);
}

if(batcheModel.getName().equals(test3)){
auditsModel= new 
AuditsModel(test3,test3,test3);
}
ListAuditsModel audits= new 
ArrayListAuditsModel();
audits.add(auditsModel);
PageableListView 
pageableListView=   (PageableListView)
AuditSelectionPage.this.get(audits);
pageableListView.setModel(new 
Model((Serializable)audits));
Label  label=(Label)get(name);
get(name).add(new 
SimpleAttributeModifier(style, color:blue;));
get(date).add(new 
SimpleAttributeModifier(style, color:blue;));
}
}

item.add(new MyLink());

/code

Michael Sparer wrote:
 
 show us some code
 
 miro wrote:
 
 I have a linkthis contains a label , now I want  to change the style
 of the label   whenever user clicks on the link ,  to do this   I
 override  the method onClick()  in  link component  I am retrieving the
 label  and adding  simpleattributemodifier to the label , but there is no
 change , when I see the generated html it does not include  the added
 style  , can I change the style of a component in  any of the   events of
 a component ?
 
 
 

-- 
View this message in context: 
http://www.nabble.com/attribute-modifier-on-onclick-tp20310246p20320579.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]



attribute modifier on onclick

2008-11-03 Thread miro

I have a linkthis contains a label , now I want  to change the style of
the label   whenever user clicks on the link ,  to do this   I override  the
method onClick()  in  link component  I am retrieving the label  and adding 
simpleattributemodifier to the label , but there is no change , when I see
the generated html it does not include  the added style  , can I change the
style of a component in  any of the   events of a component ?
-- 
View this message in context: 
http://www.nabble.com/attribute-modifier-on-onclick-tp20310246p20310246.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]



Re: attribute modifier on onclick

2008-11-03 Thread Wayne Pope
not sure but perhaps try modelchanged on the label

On Mon, Nov 3, 2008 at 9:32 PM, miro [EMAIL PROTECTED] wrote:


 I have a linkthis contains a label , now I want  to change the style of
 the label   whenever user clicks on the link ,  to do this   I override
  the
 method onClick()  in  link component  I am retrieving the label  and adding
 simpleattributemodifier to the label , but there is no change , when I see
 the generated html it does not include  the added style  , can I change the
 style of a component in  any of the   events of a component ?
 --
 View this message in context:
 http://www.nabble.com/attribute-modifier-on-onclick-tp20310246p20310246.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]