Re: CheckBox handling with Ajax.

2011-04-11 Thread vn0058212
Hi All,

I am unable to write Ajax method to make a button visible and unchecked it
should'nt be made visible.

heres my bit of code,

1.) this is like a PoP screen which comes up and i need to check the
checkbox and after which the button will be made visible and also if
unchecked it should made invisible

add(new CheckBox(A, new Model() {
@Override
public Object getObject() {
return B;
}

@Override
public void setObject(Object object) {
B= (Boolean) object;
}
}));

@Override
public boolean isVisible() {
// TODO Auto-generated method stub
return super.isVisible()  bean == null  !B;
}

@Override
protected void onSubmit() {
if (log.isDebugEnabled())
log.debug(String.format(Accepted terms of use? 
%b, B));
if (!B) {

error(getLocalizer().getString(errors.XYZ.termsOfUseNotaccepted,
Filename.this, Please accept terms of use to proceed));
return;
}
}


2.) Now this is my bit o code after i hit the button successfully and i will
abe to view the page to upload some data,

@Override
public boolean isVisible() {
// TODO Auto-generated method stub
return super.isVisible()  B;
}

@Override
protected void onSubmit() {
Filename.this.resetModel();

FileUpload upload = fileUploadField.getFileUpload();
if (log.isDebugEnabled())
log.debug(String.format(Submitted file upload: 
%s, upload));

if (upload == null) {

error(getLocalizer().getString(mapviewer.excel.no_data, Filename.this,
Please choose a file.));
return;
}


What do suggest me to do going forward?

Thanks,
Varun

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/CheckBox-handling-with-Ajax-tp1869728p3441242.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: CheckBox handling with Ajax.

2008-08-02 Thread rit

Thanks Vishy ,

this is i am already doing , issue is my ajax code is not firing , it only
fire when i click the check box. i didn't understand why it is not firing on
uncheck.

rit



vishy_sb wrote:
 
 Well you need to put the component (say component) which you want to make
 invisible into target and then set
 component.setOutputMarkupPlaceholderTag(true).
 
 Let me know if that works. 
 
 vishy
  
 
 rit wrote:
 
 I have strange situation while handling Ajax on check box.
 
 I have a scenario , On click of check box i need to hide one component
 and on uncheck i need to show the component back . when i select the
 check box my Ajax fires and component hide , but when i unselect the
 check box , my ajax doesn't fires . 
 
 Please help me . 
 
 my code is :
 
 Object obj = this.get(e_joint_cover);
  if (obj instanceof MCheckbox) {
  final MCheckbox eJointCover = 
 (MCheckbox)obj;
  eJointCover.add(new 
 AjaxFormComponentUpdatingBehavior(onclick) {
  private static final long 
 serialVersionUID = 1L;
  protected void 
 onUpdate(AjaxRequestTarget target) { 
 
 if (jointCoverValue.equalsIgnoreCase(false)){  
 
  
 //ServiceUtility.setPanelVisible(component, true);
  
 LpiComponent.setVisible(true);
  }else{
  
 //ServiceUtility.setPanelVisible(component, false);
  
 LpiComponent.setVisible(false);
  }   
  
 target.addComponent(container.get(lpi_insured_two_details_comp));
 
 
 }
  }); 
  }
 
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/CheckBox-handling-with-Ajax.-tp18781515p18790110.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: CheckBox handling with Ajax.

2008-08-02 Thread vishy_sb

Yes the code that you are putting in is for an onUpdate() method which means
that whenever the state of the checkbox gets changed only then the code will
be executed. So if you check it, something should happen and when you
uncheck it then again something should happen.

Also did u try to use the setOutputMarkupPlaceholdertag to true. I had a
similar issue like you and I was able to get it to work with that.

Vishy

vishy_sb wrote:
 
 Well you need to put the component (say component) which you want to make
 invisible into target and then set
 component.setOutputMarkupPlaceholderTag(true).
 
 Let me know if that works. 
 
 vishy
  
 
 rit wrote:
 
 I have strange situation while handling Ajax on check box.
 
 I have a scenario , On click of check box i need to hide one component
 and on uncheck i need to show the component back . when i select the
 check box my Ajax fires and component hide , but when i unselect the
 check box , my ajax doesn't fires . 
 
 Please help me . 
 
 my code is :
 
 Object obj = this.get(e_joint_cover);
  if (obj instanceof MCheckbox) {
  final MCheckbox eJointCover = 
 (MCheckbox)obj;
  eJointCover.add(new 
 AjaxFormComponentUpdatingBehavior(onclick) {
  private static final long 
 serialVersionUID = 1L;
  protected void 
 onUpdate(AjaxRequestTarget target) { 
 
 if (jointCoverValue.equalsIgnoreCase(false)){  
 
  
 //ServiceUtility.setPanelVisible(component, true);
  
 LpiComponent.setVisible(true);
  }else{
  
 //ServiceUtility.setPanelVisible(component, false);
  
 LpiComponent.setVisible(false);
  }   
  
 target.addComponent(container.get(lpi_insured_two_details_comp));
 
 
 }
  }); 
  }
 
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/CheckBox-handling-with-Ajax.-tp18781515p18790177.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]



CheckBox handling with Ajax.

2008-08-01 Thread rit

I have strange situation while handling Ajax on check box.

I have a scenario , On click of check box i need to hide one component and
on uncheck i need to show the component back . when i select the check box
my Ajax fires and component hide , but when i unselect the check box , my
ajax doesn't fires . 

Please help me . 

my code is :

Object obj = this.get(e_joint_cover);
if (obj instanceof MCheckbox) {
final MCheckbox eJointCover = 
(MCheckbox)obj;
eJointCover.add(new 
AjaxFormComponentUpdatingBehavior(onclick) {
private static final long 
serialVersionUID = 1L;
protected void 
onUpdate(AjaxRequestTarget target) { 

if (jointCoverValue.equalsIgnoreCase(false)){ 


//ServiceUtility.setPanelVisible(component, true);

LpiComponent.setVisible(true);
}else{

//ServiceUtility.setPanelVisible(component, false);

LpiComponent.setVisible(false);
}   

target.addComponent(container.get(lpi_insured_two_details_comp));


}   
}); 
}



-- 
View this message in context: 
http://www.nabble.com/CheckBox-handling-with-Ajax.-tp18781515p18781515.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]