Hi James!

I've done it now that way - there seems no other solution
to this.

thx
lukas


Am Samstag, 1. Juli 2006 15:48 schrieb James Carman:
> You can use a "value object" and bind your form fields to that.  Then, when
> you submit your form, you can create your "domain object" from your value
> object using the constructor.
>
> -----Original Message-----
> From: Lukas Ruetz [mailto:[EMAIL PROTECTED]
> Sent: Saturday, July 01, 2006 8:26 AM
> To: users@tapestry.apache.org
> Cc: [EMAIL PROTECTED]
> Subject: Re: component-binding/property side-effect (T4)
>
> Hi Henrik!
>
> Yes, I'm using sessions (comes from the authentication).
> But again - I'm doing nothing special - I just want a component
> to set attributes of a domain-object with values from a form. The
> object is provided by a parameter.
>
> Normally the attributes can be bound to the form-fields.
> But as I sayed my domain-object is immutable and the values
> can only be provided in the constructor, so the typical mapping
> is no solution - the domain-object has no setter-methods.
> I just wanted to know if there is a simple solution to this?
>
> For better understanding here some code:
>
> --- page ---
> class abstract MyPage extends BasePage {
>  public abstract DomainObj getDomainObj();
>  public abstract void setDomainObj(DomainObj obj);
>
>  public void formSubmit() {
>    DomainObj = getDomainObj();
>    // .. work with it
>  }
> ]
>
> <DEFANGED_form jwcid="@Form">
> <span jwcid="@MyComponent" domainObj="ognl:domainObj" />
> </form>
>
> --- component ---
> class abstract MyComponent extends BaseComponent {
>  private String _v1, _v2;
>
>  @Parameter(required=true)
>  public abstract DomainObj getDomainObj();
>  public abstract void setDomainObj(DomainObj obj);
>
>  public String getValue1() { return v1; }
>  public String getValue2() { return v2; }
>  public void setValue1( String v1 ) { _value1 = v1; }
>  public void setValue2( String v2 ) {
>   _value1 = v2;
>   // *** this here seems to be the problem
>   setDomainObj( new DomainObj(_1v,_v2) );
>  }
> }
>
>  <span jwcid="@TextField" value="ognl:value1" />
>  <span jwcid="@TextField" value="ognl:value2" />
> ---
>
> This is really ugly, so is there a correct way to do that? Or is
> it much more simple to wrap my immutable class in one that has
> setters for attributes?
>
> thx
> lukas
>
> Am Samstag, 1. Juli 2006 12:45 schrieb hv @ Fashion Content:
> > Hmm, could you describe the situation a bit more. Are you using sessions
>
> or
>
> > not ?
> > It sounds like you are trying to break the encapsulation of the
> > component. Are you looking to have an object attached to the page which
> > is accessed
>
> by
>
> > the component
> > and presented as a component getter ?
> > I can't think of why you would want to do that.
> >
> > But if you really want to do it, provide the page property as a parameter
> > of the component.
> >
> > Henrik
> >
> > "Lukas Ruetz" <[EMAIL PROTECTED]> skrev i en meddelelse
> > news:[EMAIL PROTECTED]
> >
> > > Hello!
> > >
> > > My current side-effect is, that I get the correct (posted)
> > > binding-value in my page-code only _once_! If I read the abstract
> > > getter a second time (still in the same request-cycle) I get an old
> > > value from a previous page-submit (a different page)!
> > >
> > > I want to have something like this:
> > > page -> binding (1 object) -> myComponent -> some properties ->
> > > form-fields
> > >
> > > I have already heard of side-effects if the property getters/setters
> > > are not managed by tapestry (abstract methods). Currently I have
> > > implemented the property-setters (in the component) my own to be able
> > > to create the resulting object out of the different (posted)
>
> form-fields.
>
> > > I can't use the usual mapping from domain-object-attributes to
> > > form-fields because the used class is immutable and the values can
> > > only be provided in the constructor.
> > >
> > > So my question is - Where to put the code that creates my resulting
> > > (immutable) object if I have to use abstract property-setters?
> > > Or is the only solution to use the typical approach and a class that
> > > just transports the values?
> > >
> > > thanks
> > > lukas

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to