Re: Dynamicly Created Checkboxes

2010-01-23 Thread Shing Hing Man
I have a running example as described by Josh below.

http://lombok.demon.co.uk/tapestry5Demo/test/components/checkboxgroupdemo

Shing


--- On Sat, 23/1/10, Josh Canfield  wrote:

> From: Josh Canfield 
> Subject: Re: Dynamicly Created Checkboxes
> To: "Tapestry users" 
> Date: Saturday, 23 January, 2010, 3:01
> > I am trying to get the submit
> results of a dynamic set of checkboxes
> > and I'm stumped.
> 
> I'm not sure what you expect the value to be? Also, I don't
> see
> t:context in the checkbox documentation, does that do
> something?
> 
> You are having trouble because you have a list of values
> going out,
> but only a single value coming back in. For each checkbox
> selected in
> the UI a value is passed back to the component. It calls
> the setter
> for each value, overwriting the previous value and leaving
> you with
> the last only the last one.
> 
> Try adding a setter for your property and collect the
> checked values in a list.
> 
> something like:
> 
>  index="listIndex">
>         t:id="checkbox" t:value="checkbox"/>${item}
> 
> 
> /** keep track of loop iterations */
> private Integer listIndex;
> 
> /** loaded with selected checkbox values */
> private List selectedItems;
> 
> /**
>  * Called with the form is posted for every checkbox that
> is checked.
>  * Use the listIndex to grab the right value from the
> original list.
>  **/
> public void setCheckbox(boolean set) {
>        if (selectedItems == null)
> selectedItems = new ArrayList();
>        
> selectedItems.add(list.get(listIndex));
> }
> 
> 
> Josh
> 
> On Thu, Jan 21, 2010 at 5:40 PM, Hilco Wijbenga
> 
> wrote:
> > Hi all,
> >
> > I am trying to get the submit results of a dynamic set
> of checkboxes
> > and I'm stumped.
> >
> > http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";>
> >  
> >    
> >      
> >         t:value="checkbox"
> > t:context="item"/>${item}
> >      
> >      
> >    
> >  
> > 
> >
> >
> > public class Test {
> >  private final String[] list = new String[] { "Abc",
> "Defg", "Hijkl", "Mno" };
> > �...@property private String item;
> > �...@property private boolean checkbox;
> >  public String[] getList() {
> >    return list;
> >  }
> > }
> >
> > If I simply add "onSuccess()" I only get the result
> for "Mno". Adding
> > one or more parameters (for item and checkbox) doesn't
> seem to work. I
> > tried various other methods and combinations but
> nothing seems to do
> > the trick.
> >
> > How do I do this?
> >
> > Cheers,
> > Hilco
> >
> >
> -
> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> > For additional commands, e-mail: users-h...@tapestry.apache.org
> >
> >
> 
> 
> 
> -- 
> --
> TheDailyTube.com. Sign up and get the best new videos on
> the internet
> delivered fresh to your inbox.
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 
> 




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



Re: Dynamicly Created Checkboxes

2010-01-22 Thread Josh Canfield
> I am trying to get the submit results of a dynamic set of checkboxes
> and I'm stumped.

I'm not sure what you expect the value to be? Also, I don't see
t:context in the checkbox documentation, does that do something?

You are having trouble because you have a list of values going out,
but only a single value coming back in. For each checkbox selected in
the UI a value is passed back to the component. It calls the setter
for each value, overwriting the previous value and leaving you with
the last only the last one.

Try adding a setter for your property and collect the checked values in a list.

something like:


   ${item}


/** keep track of loop iterations */
private Integer listIndex;

/** loaded with selected checkbox values */
private List selectedItems;

/**
 * Called with the form is posted for every checkbox that is checked.
 * Use the listIndex to grab the right value from the original list.
 **/
public void setCheckbox(boolean set) {
   if (selectedItems == null) selectedItems = new ArrayList();
selectedItems.add(list.get(listIndex));
}


Josh

On Thu, Jan 21, 2010 at 5:40 PM, Hilco Wijbenga
 wrote:
> Hi all,
>
> I am trying to get the submit results of a dynamic set of checkboxes
> and I'm stumped.
>
> http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";>
>  
>    
>      
>         t:context="item"/>${item}
>      
>      
>    
>  
> 
>
>
> public class Test {
>  private final String[] list = new String[] { "Abc", "Defg", "Hijkl", "Mno" };
> �...@property private String item;
> �...@property private boolean checkbox;
>  public String[] getList() {
>    return list;
>  }
> }
>
> If I simply add "onSuccess()" I only get the result for "Mno". Adding
> one or more parameters (for item and checkbox) doesn't seem to work. I
> tried various other methods and combinations but nothing seems to do
> the trick.
>
> How do I do this?
>
> Cheers,
> Hilco
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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



Re: Dynamicly Created Checkboxes

2010-01-22 Thread Stephan Windmüller

Am 22.01.2010 02:40, schrieb Hilco Wijbenga:


If I simply add "onSuccess()" I only get the result for "Mno". Adding
one or more parameters (for item and checkbox) doesn't seem to work.


That sounds very familiar. Please have a look at this bug report:

https://issues.apache.org/jira/browse/TAP5-869

Try it set the defer parameter of your submit component to false.

Regards
 Stephan

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



Re: Dynamicly Created Checkboxes

2010-01-21 Thread Jun Tsai
I think you should write own component to support that.


   ${item}
 

processSubmit:

request.getParameters("xxx");


2010/1/22 Hilco Wijbenga 

> Hi all,
>
> I am trying to get the submit results of a dynamic set of checkboxes
> and I'm stumped.
>
> http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";>
>  
>
>  
> t:context="item"/>${item}
>  
>  
>
>  
> 
>
>
> public class Test {
>  private final String[] list = new String[] { "Abc", "Defg", "Hijkl", "Mno"
> };
>  @Property private String item;
>  @Property private boolean checkbox;
>  public String[] getList() {
>return list;
>  }
> }
>
> If I simply add "onSuccess()" I only get the result for "Mno". Adding
> one or more parameters (for item and checkbox) doesn't seem to work. I
> tried various other methods and combinations but nothing seems to do
> the trick.
>
> How do I do this?
>
> Cheers,
> Hilco
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
regards,
Jun Tsai


Dynamicly Created Checkboxes

2010-01-21 Thread Hilco Wijbenga
Hi all,

I am trying to get the submit results of a dynamic set of checkboxes
and I'm stumped.

http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";>
  

  
${item}
  
  

  



public class Test {
  private final String[] list = new String[] { "Abc", "Defg", "Hijkl", "Mno" };
  @Property private String item;
  @Property private boolean checkbox;
  public String[] getList() {
return list;
  }
}

If I simply add "onSuccess()" I only get the result for "Mno". Adding
one or more parameters (for item and checkbox) doesn't seem to work. I
tried various other methods and combinations but nothing seems to do
the trick.

How do I do this?

Cheers,
Hilco

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