You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by htaneva <hr...@yahoo.de> on 2011/10/25 01:06:20 UTC
Using DropDownChoice to select chexboxes
Hi guys,
I have a problem, which i couldnt solve for a while. I have a
DropDownChoice control that contains a list of states(for example open and
error).
final Set<DataReleaseProduction> sel = new HashSet<DataReleaseProduction>();
private String selectedStatus = "";
final DropDownChoice comboChoice = new DropDownChoice("comboChoice",
new PropertyModel<String>(this, "selected"), new Model(
getChoices(stringOpen, stringError)),
new DropDownChoiceRenderer());
comboChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
selectedStatus = selected.getValue();
setResponsePage(getPage());
}
});
I am using a AjaxFallbackDefaultDataTable to represent the data on the
screen. Each row contains a CheckBoxColumn which is set whenever a chosen
condition from the drop-down menu has been fulfilled (state is chosen).
CheckBoxColumn<DataReleaseProduction> ckBox = new
CheckBoxColumn<DataReleaseProduction>(
Model.of("")) {
@Override
protected IModel<Boolean> newCheckBoxModel(
final IModel<DataReleaseProduction> rowModel) {
return new AbstractCheckBoxModel() {
@Override
public void unselect() {
sel.remove(rowModel.getObject());
}
@Override
public void select() {
sel.add(rowModel.getObject());
}
@Override
public boolean isSelected() {
final DataReleaseProduction d = rowModel.getObject();
final String stati = d.getState().name();
boolean isEquals = stati.equals(selectedStatus);
return isEquals;
}
@Override
public void detach() {
rowModel.detach();
}
};
}
};
The setting of the checkBox is done via the onchange event, which is
searching for the fulfillment condition in my own created object
DataReleaseProduction.
So far i got the onchange event correct working. The problem i still have is
that whenever i try to send the selected row for further processing (by
using OnSubmit), the sel-HashSet has the size of 0. From my point of view,
by choosing a state from the drop down menu, the selected rows arent stored
into the HashSet. Whenever i choose rows manually the selected rows are
stored into the set.
Do you have by any chance idea what i am doing wrong and how can i improve
my source code.
Thanks
Hristina
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Using-DropDownChoice-to-select-chexboxes-tp3934901p3934901.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Using DropDownChoice to select chexboxes
Posted by htaneva <hr...@yahoo.de>.
Hi,
thank you for your help. I have solved the problem this way:
I put custom logic that updates the sel -HashSet in the
AjaxFormComponentUpdatingBehavior of the drop down control.
Everytime when the user changes the state of the control , the objects with
the certain states are added to the sel-HashSet. Then i repaint the table
.
Select/ unselect and submit work fine.
Hristina
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Using-DropDownChoice-to-select-chexboxes-tp3934901p3955852.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Using DropDownChoice to select chexboxes
Posted by htaneva <hr...@yahoo.de>.
http://apache-wicket.1842946.n4.nabble.com/file/n3936768/myproject-1.0-SNAPSHOT-sources.jar
myproject-1.0-SNAPSHOT-sources.jar
Hi,
i uploaded a simple demo application for the described problem. It is named
myproject. The HomePage contains all all the necessary components that
reproduce the problem. There is also a FeedbackPanel that provides an
information about the selected objects. I tried to describe some test cases
in the comments.
Thank you in advance for your help!
Hristina
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Using-DropDownChoice-to-select-chexboxes-tp3934901p3936768.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Using DropDownChoice to select chexboxes
Posted by Martin Grigorov <mg...@apache.org>.
On Tue, Oct 25, 2011 at 10:46 AM, htaneva <hr...@yahoo.de> wrote:
> Hi,
>
> "selected" ist the SelectOption that is set in the model that the drop down
> uses. I used the first example from the wiki:
> https://cwiki.apache.org/WICKET/dropdownchoice-examples.html
>
> How can i directly update this.selectedStatus?
final DropDownChoice comboChoice = new DropDownChoice("comboChoice",
new PropertyModel<String>(this,
"selectedStatus"), new Model( // note that I changed selected ->
selectedStatus
getChoices(stringOpen,
stringError)),
new DropDownChoiceRenderer());
comboChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
// selectedStatus already has the new value
setResponsePage(getPage());
}
});
>
> It is an AjaxButton OnSubit action.
>
Probably you'll have to upload somewhere a demo application that we
can debug and tell you what is wrong...
> Hristina
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Using-DropDownChoice-to-select-chexboxes-tp3934901p3936047.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Using DropDownChoice to select chexboxes
Posted by htaneva <hr...@yahoo.de>.
Hi,
"selected" ist the SelectOption that is set in the model that the drop down
uses. I used the first example from the wiki:
https://cwiki.apache.org/WICKET/dropdownchoice-examples.html
How can i directly update this.selectedStatus?
It is an AjaxButton OnSubit action.
Hristina
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Using-DropDownChoice-to-select-chexboxes-tp3934901p3936047.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Using DropDownChoice to select chexboxes
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
On Tue, Oct 25, 2011 at 1:06 AM, htaneva <hr...@yahoo.de> wrote:
> Hi guys,
>
> I have a problem, which i couldnt solve for a while. I have a
> DropDownChoice control that contains a list of states(for example open and
> error).
>
> final Set<DataReleaseProduction> sel = new HashSet<DataReleaseProduction>();
> private String selectedStatus = "";
>
> final DropDownChoice comboChoice = new DropDownChoice("comboChoice",
> new PropertyModel<String>(this, "selected"), new Model(
what is this.selected ? And why you don't directly update this.selectedStatus ?
> getChoices(stringOpen, stringError)),
> new DropDownChoiceRenderer());
>
> comboChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
> @Override
> protected void onUpdate(AjaxRequestTarget target) {
> selectedStatus = selected.getValue();
>
> setResponsePage(getPage());
You use AjaxFCUBehavior but at the end of repaint the whole page.
You can use org.apache.wicket.markup.html.form.DropDownChoice.wantOnSelectionChangedNotifications()
instead.
>
> }
> });
>
>
> I am using a AjaxFallbackDefaultDataTable to represent the data on the
> screen. Each row contains a CheckBoxColumn which is set whenever a chosen
> condition from the drop-down menu has been fulfilled (state is chosen).
>
>
> CheckBoxColumn<DataReleaseProduction> ckBox = new
> CheckBoxColumn<DataReleaseProduction>(
> Model.of("")) {
>
> @Override
> protected IModel<Boolean> newCheckBoxModel(
> final IModel<DataReleaseProduction> rowModel) {
>
> return new AbstractCheckBoxModel() {
>
> @Override
> public void unselect() {
> sel.remove(rowModel.getObject());
> }
>
> @Override
> public void select() {
> sel.add(rowModel.getObject());
> }
>
> @Override
> public boolean isSelected() {
> final DataReleaseProduction d = rowModel.getObject();
> final String stati = d.getState().name();
>
> boolean isEquals = stati.equals(selectedStatus);
> return isEquals;
>
> }
>
> @Override
> public void detach() {
> rowModel.detach();
> }
>
> };
> }
>
> };
>
>
> The setting of the checkBox is done via the onchange event, which is
> searching for the fulfillment condition in my own created object
> DataReleaseProduction.
>
> So far i got the onchange event correct working. The problem i still have is
> that whenever i try to send the selected row for further processing (by
> using OnSubmit), the sel-HashSet has the size of 0. From my point of view,
what is OnSubmit() ? The form's or some (ajax)button's ?
> by choosing a state from the drop down menu, the selected rows arent stored
> into the HashSet. Whenever i choose rows manually the selected rows are
> stored into the set.
>
> Do you have by any chance idea what i am doing wrong and how can i improve
> my source code.
>
> Thanks
> Hristina
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Using-DropDownChoice-to-select-chexboxes-tp3934901p3934901.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com