Component creation and initialization

2009-05-14 Thread Juan G. Arias
Hi all,
Is there a way in wicket for separate the object's instantiation phase from
the inner component's creation phase?
Just like the "init()" method in application, but for my components.

Another way to see it, just in case it's not clear:
Is there an already defined contract for component creation, that allows me
to create the components I will use in some panel/page, but not to do it in
the Java constructor?

Thanks in advance!
Juan


Re: Component creation and initialization

2009-05-14 Thread Juan G. Arias
It would be very nice to add a new phase for component creation, like I
said, an init() or createContent().
Is there a JIRA issue for that?
If yes, I will vote for it and suggest to change the name to something _not_
related to the rendre phase.

Thanks!
Juan


On Thu, May 14, 2009 at 3:31 PM, Daniel Stoch wrote:

> I think you can use hasBeenRendered() method instead of custom boolean
> flag.
>
> --
> Daniel
>
> On 2009-05-14, at 20:15, Jeremy Thomerson wrote:
>
>  You could probably do it in onBeforeRender - but you would need to
>> keep a boolean flag to check if it's the first render so that you
>> don't recreate them on a second render  There was talking of
>> adding an onBeforeFirstRender method, but I don't think it's happened
>> yet - you could look for the method to see if I'm wrong.
>>
>> --
>> Jeremy Thomerson
>> http://www.wickettraining.com
>>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


IRequestTarget not serializable

2009-05-21 Thread Juan G. Arias
Hi all,
I want to mantain an IRequestTarget in my component, as an instance
attribute. But wicket cries about it's not serializable.
Of course, it's right. IRequestTarget is not serializable.

Why? Is something wrong with mantain a request target inside my component?

Thanks!
Juan


Re: IRequestTarget not serializable

2009-05-22 Thread Juan G. Arias
I have this link, that I create in different ways. It performs some logic,
and then redirects to somewhere, depending on how was created.
Here is the code:

class SignOutLink extends Link {
  private IRequestTarget target;

  public SignOutLink(String id, Class redirectPage) {
  this(id, new BookmarkablePageRequestTarget(redirectPage));
  }

  public SignOutLink(String id, String url) {
  this(id, new RedirectRequestTarget(url));
}

  public SignOutLink(String id, IRequestTarget target) {
  super(id);
  this.target = target;
  }

  public void onClick() {
  this.signOutSession();
this.redirectSignInPage();
  }

  public abstract void signOutSession();

  public void redirectSignInPage() {
  this.getRequestCycle().setRequestTarget(this.target);
  }
}


On Thu, May 21, 2009 at 8:08 PM, Matej Knopp  wrote:

> IRequestTarget is valid only for one request. Why do you want to keep
> as instance variable?
>
> -Matej
>
> On Thu, May 21, 2009 at 11:48 PM, Juan G. Arias 
> wrote:
> > Hi all,
> > I want to mantain an IRequestTarget in my component, as an instance
> > attribute. But wicket cries about it's not serializable.
> > Of course, it's right. IRequestTarget is not serializable.
> >
> > Why? Is something wrong with mantain a request target inside my
> component?
> >
> > Thanks!
> > Juan
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: IRequestTarget not serializable

2009-05-22 Thread Juan G. Arias
Ooook, thanks a lot!

On Fri, May 22, 2009 at 10:49 AM, James Carman  wrote:

> For me, I store a page "reference".  So, as Matej suggested, you could
> have two different type of callbacks.  One, a PageReferenceCallback
> and another BookmarkablePageCallback?
>
> On Fri, May 22, 2009 at 9:46 AM, Joe Fawzy  wrote:
> > hi dearu have to process the target during its lifecycle time and store
> that
> > result into something serializable for future use
> > so u have to make the decision during the first request where the request
> > target is valid not the second
> > joe
> >
> > On Fri, May 22, 2009 at 4:34 PM, Juan G. Arias 
> wrote:
> >
> >> I have this link, that I create in different ways. It performs some
> logic,
> >> and then redirects to somewhere, depending on how was created.
> >> Here is the code:
> >>
> >> class SignOutLink extends Link {
> >>  private IRequestTarget target;
> >>
> >>  public SignOutLink(String id, Class redirectPage) {
> >>  this(id, new BookmarkablePageRequestTarget(redirectPage));
> >>  }
> >>
> >>  public SignOutLink(String id, String url) {
> >>  this(id, new RedirectRequestTarget(url));
> >>}
> >>
> >>  public SignOutLink(String id, IRequestTarget target) {
> >>  super(id);
> >>  this.target = target;
> >>  }
> >>
> >>  public void onClick() {
> >>  this.signOutSession();
> >> this.redirectSignInPage();
> >>  }
> >>
> >>  public abstract void signOutSession();
> >>
> >>  public void redirectSignInPage() {
> >>  this.getRequestCycle().setRequestTarget(this.target);
> >>   }
> >> }
> >>
> >>
> >> On Thu, May 21, 2009 at 8:08 PM, Matej Knopp 
> >> wrote:
> >>
> >> > IRequestTarget is valid only for one request. Why do you want to keep
> >> > as instance variable?
> >> >
> >> > -Matej
> >> >
> >> > On Thu, May 21, 2009 at 11:48 PM, Juan G. Arias  >
> >> > wrote:
> >> > > Hi all,
> >> > > I want to mantain an IRequestTarget in my component, as an instance
> >> > > attribute. But wicket cries about it's not serializable.
> >> > > Of course, it's right. IRequestTarget is not serializable.
> >> > >
> >> > > Why? Is something wrong with mantain a request target inside my
> >> > component?
> >> > >
> >> > > Thanks!
> >> > > Juan
> >> > >
> >> >
> >> > -
> >> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >> > For additional commands, e-mail: users-h...@wicket.apache.org
> >> >
> >> >
> >>
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Default implementation of IChainingModel

2009-04-08 Thread Juan G. Arias
Hi all,First of all, I'm using wicket 1.3.5

I'm writing a model and ai need it to be "chaineable". I mean, I need this
model to contain another model, so my model can obtain the data, for
example, from a property model.
Ok, I've been reading and this is solved by the IChainingModel.

But I couldn't find any default implementation of this interface.
There are two classes currently implementing this interface,
AbstractPropertyModel and CompoundPropertyModel.
Both classes has some code duplicated, specifically:
- void detach()
- IModel getChainedModel()
- void setChainedModel(IModel model)
- some lines of void setObject(Object object)
- the code in CompuntPropertyModel#getObject() and
AbstarctPropertyModel#getTarget() is different, but the logic is the same.

And I'm afraid my code will be the same as those classes.

So, finally, my point.
Is there any default implementation of this behavior? Is there a chance to
add a super-class with this code?

Thanks!
Juan Arias


How to send data to server - form submission

2009-04-22 Thread Juan G. Arias
Hi all,I wanted to check with you if my reasoning is ok.

I have my model object, bound to some controls displayed in the page using
PropertyModel.
I also have one ajax event (using a simple AjaxLink).

When the user clicks this ajax link, some components in the page are added
to the ajax target in order to be updated.
And the components linked to my model object resets to their original
values.

This is happening because there is no submission of information from
browser, that's ok.

One possible solution to this is to add a form component, surrounding my
components. And replace the AjaxLink with a AjaxSubmitLink.
That would submit information from the form in the browser, update my model,
and finally render the components updated.

Finally, the question: Is there any other option to do this? Does wicket
have some component to send information via ajax without a form?

Form submission is the regular way to send information from browser to
server, in regular (no ajax) pages.
I understand that AjaxSubmitLink doesn't submit the whole page, only the
form, and that's nice.
But i wonder if there is some alternate way to link properties to
components.

Thanks in advance!
Juan


Re: How to send data to server - form submission

2009-04-22 Thread Juan G. Arias
The html and the object component hierarchy would be simplier.My question is
why stay attached to the HTML standard (use forms to submit), if AJAX
doesn't need to.

I need this inside a form, and only for one or maybe two text fields.
If I can link the component to the model without a form, I think it might be
better.

Do you agree?

On Wed, Apr 22, 2009 at 4:15 PM, Jeremy Thomerson  wrote:

> Why do you want an alternate way?  Is there some advantage you see?
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
>
> On Wed, Apr 22, 2009 at 2:10 PM, Juan G. Arias 
> wrote:
> > Hi all,I wanted to check with you if my reasoning is ok.
> >
> > I have my model object, bound to some controls displayed in the page
> using
> > PropertyModel.
> > I also have one ajax event (using a simple AjaxLink).
> >
> > When the user clicks this ajax link, some components in the page are
> added
> > to the ajax target in order to be updated.
> > And the components linked to my model object resets to their original
> > values.
> >
> > This is happening because there is no submission of information from
> > browser, that's ok.
> >
> > One possible solution to this is to add a form component, surrounding my
> > components. And replace the AjaxLink with a AjaxSubmitLink.
> > That would submit information from the form in the browser, update my
> model,
> > and finally render the components updated.
> >
> > Finally, the question: Is there any other option to do this? Does wicket
> > have some component to send information via ajax without a form?
> >
> > Form submission is the regular way to send information from browser to
> > server, in regular (no ajax) pages.
> > I understand that AjaxSubmitLink doesn't submit the whole page, only the
> > form, and that's nice.
> > But i wonder if there is some alternate way to link properties to
> > components.
> >
> > Thanks in advance!
> > Juan
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: How to send data to server - form submission

2009-04-23 Thread Juan G. Arias
I don't see why having multiple ways to send information is reinventing the
wheel.
My point was that form submission is a standard for send information. Is the
classic way.
Ajax doesn't require this. You are able to send information on any
javascript event. And maybe someone had implemented that.

I agree is simpler to have only one entry point. And has consistency, seems
robust.
Wicket triggers the same "conceptual" event, form submission. No matter how
this is triggered, regular sumit or ajax.

Finally, I will add the form component and send info using the standard way.

Thanks!
Juan

On Wed, Apr 22, 2009 at 6:12 PM, Jeremy Thomerson  wrote:

> Not really - I'd liken that to reinventing the wheel.  Wicket provides
> easy support for linking the component and the model through an ajax
> event - form submission.  But, you could probably write your own JS
> that takes advantage of the wicket-ajax stuff and manually sends the
> form values as parameters on the ajax request, etc...
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
>
> On Wed, Apr 22, 2009 at 4:06 PM, Juan G. Arias 
> wrote:
> > The html and the object component hierarchy would be simplier.My question
> is
> > why stay attached to the HTML standard (use forms to submit), if AJAX
> > doesn't need to.
> >
> > I need this inside a form, and only for one or maybe two text fields.
> > If I can link the component to the model without a form, I think it might
> be
> > better.
> >
> > Do you agree?
> >
> > On Wed, Apr 22, 2009 at 4:15 PM, Jeremy Thomerson <
> jer...@wickettraining.com
> >> wrote:
> >
> >> Why do you want an alternate way?  Is there some advantage you see?
> >>
> >> --
> >> Jeremy Thomerson
> >> http://www.wickettraining.com
> >>
> >>
> >>
> >>
> >> On Wed, Apr 22, 2009 at 2:10 PM, Juan G. Arias 
> >> wrote:
> >> > Hi all,I wanted to check with you if my reasoning is ok.
> >> >
> >> > I have my model object, bound to some controls displayed in the page
> >> using
> >> > PropertyModel.
> >> > I also have one ajax event (using a simple AjaxLink).
> >> >
> >> > When the user clicks this ajax link, some components in the page are
> >> added
> >> > to the ajax target in order to be updated.
> >> > And the components linked to my model object resets to their original
> >> > values.
> >> >
> >> > This is happening because there is no submission of information from
> >> > browser, that's ok.
> >> >
> >> > One possible solution to this is to add a form component, surrounding
> my
> >> > components. And replace the AjaxLink with a AjaxSubmitLink.
> >> > That would submit information from the form in the browser, update my
> >> model,
> >> > and finally render the components updated.
> >> >
> >> > Finally, the question: Is there any other option to do this? Does
> wicket
> >> > have some component to send information via ajax without a form?
> >> >
> >> > Form submission is the regular way to send information from browser to
> >> > server, in regular (no ajax) pages.
> >> > I understand that AjaxSubmitLink doesn't submit the whole page, only
> the
> >> > form, and that's nice.
> >> > But i wonder if there is some alternate way to link properties to
> >> > components.
> >> >
> >> > Thanks in advance!
> >> > Juan
> >> >
> >>
> >> -
> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >> For additional commands, e-mail: users-h...@wicket.apache.org
> >>
> >>
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>