-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Editing a collection of value types
PostPosted: Wed Nov 02, 2005 7:33 pm 
Senior
Senior

Joined: Sat Sep 10, 2005 3:46 pm
Posts: 178
I am just wondering how best to handle a list of value types that are displayed in a data list. For example, I have an entity called Document, Document has a set of Links. Links are a value type and mapped as collection of composite elements.

I display the list of links in a data grid. I want the ability to edit a a Link if the url has changed. So how do I handle the editing of a value type if it doesnt have an identity. Generally, Value types are immutable and that is ok. I would just create a new Link object and Delete the old, but Im still not sure how to find the Link to delete in the list after a postback. Usually, with a Datagrid displaying entities, you can use the entity id as the key. Having a key makes it easy to find the item. I guess Im just confused about how to get the value type if it has no key.

Thanks for any help.


Top
 Profile  
 
 Post subject: Re: Editing a collection of value types
PostPosted: Thu Nov 03, 2005 6:23 am 
jnapier wrote:
..., but Im still not sure how to find the Link to delete in the list after a postback. Usually, with a Datagrid displaying entities, you can use the entity id as the key. Having a key makes it easy to find the item. I guess Im just confused about how to get the value type if it has no key.


So, as I understand, the main problem is to find item in grid. In this case you can use CommandName and CommandArgument for grid command handling. For example you put "Delete" button into the grid with CommandName="delete" and CommandArgument="<%# bind your unique link attribute here %>". Now in your grid.ItemCommand eventhadler method (or grid.DeleteCommand) you can check eventargs (e.commandName and e.CommandArgument) for your options and here you can use serch by your CommandArgument value.

Note, than your CommandArgument can be composite, something like <DocumentId>_<LinkName>.


Top
  
 
 Post subject:
PostPosted: Thu Nov 03, 2005 11:50 am 
Senior
Senior

Joined: Sat Sep 10, 2005 3:46 pm
Posts: 178
Ghen,
I think what you are trying to say is that I must have some kind of key. this key must be unique. For example the link name must be unique. Then I must search through the collection to find the value.

The only gotcha I guess is that the key must be unique. This cant always be guranteed with value types, but I guess there isnt really an alternative. I have to be able to identify the value somehow.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.