Re: properties not persisting across requests

2011-09-14 Thread Steve Eynon
It looks like you want 'itemsPerPage' to be a Parameter as well as
being persisted. As @Parameter and @Persist cannot be placed on the
same field one approach is to persis the field in the Page and pass it
down to the Gallery component. The the code is then just as Robert
says:

Home.java

@Property
@Persist
private int itemsPerPage;

Home.tml

t:gallery itemsPerPage=prop:itemsPerPage /

Gallery.java:

@Parameter(required=true, value=literal:50)
@Property
private int itemsPerPage

Gallery.tml:
 t:select t:value=itemsPerPage .../

Steve.

On 14 September 2011 12:29, Ken in Nashua kcola...@live.com wrote:

 Well I got the gallery component wrapped in a form so I think I need to 
 probably actually perform a submit...
 So I rigged up my handlers and did the submit...

 Still no luck... select keep reverting back to default on refresh


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



Re: properties not persisting across requests

2011-09-14 Thread Thiago H. de Paula Figueiredo
On Wed, 14 Sep 2011 00:14:11 -0300, Ken in Nashua kcola...@live.com  
wrote:


I need a default value in order to load my collection... otherwise this  
variable is interpreted as null or 0...depending on which type I use...  
Integer, String or int

How would you set a default ?


Use onActivate() or @BeginRender.

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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



RE: properties not persisting across requests

2011-09-14 Thread Ken in Nashua

Hey thanks Thiago... that worked nicely... just what I needed... for 
initialization... still figuring out the refresh logic...



t:label for=itemsPerPageSelectItems Per Page/t:label
select t:type=select t:id=itemsPerPageSelect

t:model=literal:5,10,15,25,50,100,250,500,1000,5000,1
value=itemsPerPage
onchange=this.form.submit()
/


@Persist(session)
@Property(read = true, write = true)
private int itemsPerPage;

@Component(parameters = {clientId=itemsPerPageSelect})
private Select itemsPerPageSelect;

public Object onActionFromItemsPerPageSelect()
{
logger.info(In itemsPerPageChangeListener : );
}



I got the gallery items editing now too on click... and just wired up the 
handlers...



Kinda stuck on the onchange handler for the select control though...


I dont know how to get a breakpoint to happen at the handler.

Any ideas?

I tried several variations of handler right on th emethod as follows without 
luck...

//@OnEvent(value = action, component = select)
//@OnEvent(value = itemsPerPageChange, component = itemsPerPageSelect)
//@EventListener(events =
//{ onchange }, targets =
//{ itemsPerPageSelect }, submitForm = galleryForm, async = true)


When I am done with this I will post it and see who can soup this 
gallery up further... I got entity object rendering already... just by 
specifying an entity class as the type.



its looking like within th enext 14 days I will have something to share

Thanks
kcola...@live.com
 



 To: users@tapestry.apache.org; kcola...@live.com
 Subject: Re: properties not persisting across requests
 Date: Wed, 14 Sep 2011 08:39:25 -0300
 From: thiag...@gmail.com
 
 On Wed, 14 Sep 2011 00:14:11 -0300, Ken in Nashua kcola...@live.com  
 wrote:
 
  I need a default value in order to load my collection... otherwise this  
  variable is interpreted as null or 0...depending on which type I use...  
  Integer, String or int
  How would you set a default ?
 
 Use onActivate() or @BeginRender.
 
 -- 
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
 and instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br
  

Re: properties not persisting across requests

2011-09-14 Thread Josh Canfield
Hey Thiago.

 You can't use @Component and declare the component in the template at the
 same time. One or other, not both.

I don't understand what you mean by this. You have to have the
component in the template, you can leave off the t:type though.

Josh

On Wed, Sep 14, 2011 at 1:27 PM, Thiago H. de Paula Figueiredo
thiag...@gmail.com wrote:
 On Wed, 14 Sep 2011 16:40:51 -0300, Ken in Nashua kcola...@live.com wrote:

 Hey thanks Thiago...

 Hi!

    @Component(parameters = {clientId=itemsPerPageSelect})
    private Select itemsPerPageSelect;

 You can't use @Component and declare the component in the template at the
 same time. One or other, not both.

   public Object onActionFromItemsPerPageSelect()
    {
        logger.info(In itemsPerPageChangeListener : );
    }

 Select doesn't trigger an action event, so your method will never be
 invoked. Check the Select documentation to know what events it triggers and
 when:
 http://tapestry.apache.org/current/tapestry-core/ref/org/apache/tapestry5/corelib/components/Select.html.
 Instead, handle the success event of the Form surrounding the Select
 component.

 --
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
 instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br

 -
 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: properties not persisting across requests

2011-09-14 Thread Thiago H. de Paula Figueiredo
On Wed, 14 Sep 2011 17:53:38 -0300, Josh Canfield joshcanfi...@gmail.com  
wrote:



Hey Thiago.


Hi, Josh!

You can't use @Component and declare the component in the template at  
the same time. One or other, not both.


I don't understand what you mean by this. You have to have the
component in the template, you can leave off the t:type though.


Well, I should have said that you shouldn't use @Component and component  
definition parameters for *the same component instance at the same time*  
instead of you can't. If you use @Component, you're at least supposed to  
define the component type and parameters in the annotation itself, leaving  
just the t:id in the template. Defining parameters for the same component  
instance in two different places is a recipe for confusion.


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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



RE: properties not persisting across requests

2011-09-13 Thread Ken in Nashua

Thanks Steve...

I am trying that... 

There is no way to set default value though...

Error persisting field Home:gallerywidget:itemsPerPage: Persistent 
fields may not be updated until after the page has finished loading. 
This may be due to a persistent field with a default value. The default 
value should be removed.

I need a default value in order to load my collection... otherwise this 
variable is interpreted as null or 0...depending on which type I use... 
Integer, String or int

How would you set a default ?
  

RE: properties not persisting across requests

2011-09-13 Thread Ken in Nashua

Also wondered why @Parameter could not do the job...

way I see it is components take parameters... and I wanted to adhere to that... 
but every time I hit refresh button I lose my state.
  

RE: properties not persisting across requests

2011-09-13 Thread Ken in Nashua

Well I got rid of defaults and ran it...

My home page contains a gallery component

I have a button rigged on my browser set to
http://localhost:8080/Home

I clock the launch button set to the above URL
The page comes up... and I see the first element in the select visible 

So I change the value of the select to another...

Then I re-click my browser button... (which I assume invokes a refresh)

and the select value reverts back to  the first element in the select 
instead of the one I set it to.

Is this a bug ? I am using tap-5.3.0

Thanks
  

Re: properties not persisting across requests

2011-09-13 Thread Robert Zeigler
Home.java:

@Property
@Persist
private int itemsPerPage;


Gallery.java:

@Parameter(required=true, cache=true, value=50)
@Property
private int itemsPerPage

Gallery.tml:
  t:select t:id=itemsPerPage .../


You've got defaultPrefix set as 50.  Default prefix refers to the default 
interpretation of a bound value. The default defaultPrefix ;) is prop.
So when a user does:

@Component(parameters={itemsPerPage=50})
private Gallery gallery;

The value 50 would be handled by the property expression binding (which knows 
how to interpret integers). Other possible values are literal (the value is 
taken 'as is', possibly with type coercion), message (the value is 
interpreted as the key in the message catalog), or validate (the value is 
transformed into a field validator).  So you definitely don't want 50 as the 
defaultPrefix. :) What you want is to set the default value.

To set the default parameter value, either use the default method, in this 
case:

int defaultItemsPerPage() {
  return 50;
}

Or else use the value attribute of the @Parameter annotation, as I did above.


Robert

On Sep 12, 2011, at 9/1211:51 PM , Ken in Nashua wrote:

 
 
 Hi All,
 
 I have page Home and a component Gallery whereby the page contains the 
 component.
 
 So I tell the page to house a variable itemsPerPage so I can persist it into 
 the component and I rig the component so accommodate and retain the state of 
 this variable.
 
 Nothing get persisted or initialized and when I hit refresh any values I set 
 on the select control get wiped out.
 
 Are there limitation to using String, int, Integer ?
 
 Home.java
@Persist
@Property(read = true, write = true)  
//@Parameter(required = false, cache = true, defaultPrefix = 50)  
private int itemsPerPage;
 
 Gallery.java
@Persist
//@Property(read = true, write = true)
//@Parameter(required = true, cache = true, defaultPrefix = 50)
private int itemsPerPage;
 
@Component(parameters = {clientId=itemsPerPageSelect})
private Select itemsPerPageSelect;
 
@OnEvent(value = itemsPerPageChange, component = select)
public Object onItemsPerPageChange()
{
}
 
 nothing seems to work... ideally I would like to use Integer
 
 Gallery.tml
t:label for=itemsPerPageSelectItems Per Page/t:label
select t:type=select t:id=itemsPerPageSelect

 t:model=literal:5,10,15,25,50,100,250,500,1000,5000,1
value=itemsPerPage
defaultValue=50
onchange=tapestry.form.refresh(this.form)
/
 
 I am having trouble with PERSIST, PROPERTY and PARAMETER... nomatter what 
 combinations I try with initialized value or not I produce every app 
 exception possible and if I do get it running... nothing gets persisted.
 
 Any help is appreciated.
 Best Regards and thanks
 Ken
 
 


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



RE: properties not persisting across requests

2011-09-13 Thread Ken in Nashua

@Persist(session)
@Property(read = true, write = true)
//@Parameter(required = true, cache = true, defaultPrefix = 50)
private int itemsPerPage;


This is what I have so far...
Nothing gets persisted...

blue in the face

Any suggestions ?

Thank You
  

RE: properties not persisting across requests

2011-09-13 Thread Ken in Nashua

Well I got the gallery component wrapped in a form so I think I need to 
probably actually perform a submit... 
So I rigged up my handlers and did the submit...

Still no luck... select keep reverting back to default on refresh