Ok. A little example from my code then. :-)

I use this for tagging accounts and therefor I have a class called AccountTag:
@Entity
public class AccountTag extends AbstractBaseEntity implements Serializable {
    private static final long serialVersionUID = -6290070624732905399L;

    @ManyToOne(fetch = FetchType.EAGER, optional = false)
    @JoinColumns(@JoinColumn(name = "accountId"))
    private Account account;

    @ManyToOne(fetch = FetchType.EAGER, optional = false)
    @JoinColumns(@JoinColumn(name = "tagId"))
    private Tag tag;

    public Account getAccount() {
        return this.account;
    }

    public void setAccount(final Account account) {
        this.account = account;
    }

    public Tag getTag() {
        return this.tag;
    }

    public void setTag(final Tag tag) {
        this.tag = tag;
    }

    public String getTagName() {
        return this.tag.getName();
    }
}

My Account-class have a Set of AccountTag:
private final Set<AccountTag> tags = Sets.newHashSet();

The list of available tags are provided to the ValueEncoder in the
get-method (previously retrieved from the database):
    public ValueEncoder<AccountTag> getTagEncoder() {
        return new GenericValueEncoder<AccountTag>(this.tags,
"tagName", this.propertyAccess);
    }

The GenericValueEncoder is Daniel Jue's code from
http://wiki.apache.org/tapestry/Tapestry5SelectObject.

And in the template:
<div t:type="tag/tagselect" t:id="tags" t:value="editAccount.tags"
t:encoder="tagEncoder"></div>

As long as the field that t:value points to is updated with the
correct values the component should contain the correct values after
an update as well.

/Joakim


On Tue, Aug 9, 2011 at 9:52 PM, George Christman
<gchrist...@cardaddy.com> wrote:
> Yes I think it's an excellent start and very useful.
>
> I'm slightly confused with using an object.
>
> I have a list of users with a one to many relationship to a purchase request
> table. I gave it a value encoder and gave the tagselect value
> "pr.authorizor". Where I'm confused is the authorizer is just the user
> object and doesn't contain the list. I'm not entirely sure how to pass both
> the list and the object into the component. Perhaps you could show me an
> example of how you do it. I know with a loop we'd use source for the list
> and value for the object.
>
> I'd love to contribute to your project, but I don't think I know enough
> about custom tapestry components just yet. Not sure how to even run them
> locally to test. Any articles or docs would be appreciated though
>
> This could be an excellent alternative to very large select menus. I like
> how it has similar actions to autocomplete, but limits your choices to only
> what is available in the list while giving you the remove x. That would be
> the only reason I'd like to limit the result set to possible one.
>
> the issue I'm having when using greater than less than might end up being
> resolved when using object values rather than strings.
>
> When a user populates the input field and saves the form, I'd like to see
> the saved values reloaded back into the input field maintaining original
> format when updating page at a later time.
>
> --
> View this message in context: 
> http://tapestry.1045711.n5.nabble.com/ANN-Tapestry-tagselect-version-1-0-released-tp4639340p4683389.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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

Reply via email to