CheckBox Behaviour through AJAX

2011-04-11 Thread vn0058212
Hi All,

I am unable to write Ajax method to make a button visible and when 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-Behaviour-through-AJAX-tp3441246p3441246.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 Behaviour through AJAX

2011-04-11 Thread lucast
Hi Varum,
I was in a sort of similar predicament a couple of weeks ago. 
Instead of using  new CheckBox(A, new Model() ... 
Have you tried using CheckBox(A, new AbstractCheckBoxModel ... ??

It was recommended by Igor (who recently published a wicket book).
Have a look how it is meant to be used. You might find that it fits your
needs.
I'm still a wicket newbie, but I couldn't find ajax behaviour for
checkboxes.

If i was to get past this problem (not that I recommend it), I'd mask a form
button as a checkbox and attach ajax behaviour to it.
But that's what I, as a wicket newbie would do. 
I hope that helps.


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/CheckBox-Behaviour-through-AJAX-tp3441246p3441440.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