• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Strange behavior with checkboxes in subcomponent - SOLVED
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Strange behavior with checkboxes in subcomponent - SOLVED


  • Subject: Strange behavior with checkboxes in subcomponent - SOLVED
  • From: Marcos Trejo Munguia <email@hidden>
  • Date: Fri, 21 Oct 2005 17:54:27 -0500

Thanks Ken.

Knowing the problem I found the next solution, if I put a dummy variable with any value and I bound this variable to a WOHiddenField, then always is a value set on the form.


On Oct 21, 2005, at 11:13 AM, Ken Anderson wrote:

This is because the phase that moves that data into your fields is being optimized out because there were no values set on the form.  Annoying, right?

The simple solution is to wipe out your array before takeValuesFromRequest() so that, if the form is empty, you actually have what you expected.  If the form has checks, they will be reset.  I can't remember how I did this last time, but I probably overrode appendToResponse() and blanked the checked array after calling super.  I don't think overriding takeValuesFromRequest will work because I don't think it ever gets called...  If I can find the code, I'll reply again!

Ken

On Oct 21, 2005, at 11:46 AM, Marcos Trejo Munguia wrote:

Hi list

I'm having a problem with a reusable component, this component shows a list of items and you can select from 1 to n of them with a checkbox next to each item. Here is the code:

  //Array with the selected items, this is initiallited by the parent component
  protected NSMutableArray receptionsSelected;
  //Item for WORepetion(Items to select)
  protected POReceptionDetail receptionItem;
  //Cancell callback
  protected String cancelCallback;
  //Submit callback
  protected String submitCallback;

The next methods are bound to the checked binding of the checkboxes

  protected boolean checked() {
  return receptionsSelected.containsObject(receptionDetailItem);
  }
 
  protected void setChecked(boolean isItChecked) {
  boolean wasItChecked = checked();
  if(isItChecked && !wasItChecked) {
  receptionsSelected.addObject(receptionItem);
  }
  else if(!isItChecked && wasItChecked) {
  receptionsSelected.removeObject(receptionItem);
  }
  }
 
I have this method to select all Items:

  protected void selectAll() {
  Enumeration i = po.poReceptionsOpen().objectEnumerator();
  while (i.hasMoreElements()) {
  POReceptionDetail iterator = (POReceptionDetail) i.nextElement();
  if (!receptionsSelected.containsObject(iterator)) {
  receptionsSelected.addObject(iterator);
  }
  }
  }
 
Callback methods, this are bound to the action binding of a WOActiveImage respectively:

  protected void cancel() {
  performParentAction(cancelCallback);
  }
 
  protected void submit() {
  performParentAction(submitCallback);
  }

Here is the submit parent action:

  public void submitSelection() {
  if (receptionsSelected.count() == 0) {
  errMsg = "There are no receptions selected";
  }
  else {
  stepController = 3;
  }
  }

Here comes the odd thing, if I select all items with selectAll and then I deselect all and click submit, the selection doesn't disappear, but if I change the WOActiveImage of submit to a WOSubmitButton everything works fine.

Please somebody give me a clue, what I'm doing wrong? _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Strange behavior with checkboxes in subcomponent (From: Marcos Trejo Munguia <email@hidden>)
 >Re: Strange behavior with checkboxes in subcomponent (From: Ken Anderson <email@hidden>)

  • Prev by Date: Re: Web Based EOModeler?
  • Next by Date: Re: Web Based EOModeler?
  • Previous by thread: Re: Strange behavior with checkboxes in subcomponent
  • Next by thread: EOModeler - Unable to connect to MySQL server
  • Index(es):
    • Date
    • Thread