Hi Mick, I'm not using Struts but a home baked framework; the idea should be the same though. I'm using Stateless Session Beans to keep the business logic, and the UI is based on XSLT so everything is seperated as well. Anyway, The application is a repository of links, so I have an entity bean called TgidDirectorio (directories) that has a N-M relationship with the entity bean called TgidReferencia (references=links). Here it is a piece of code where the relationship is modified.
// parentDirectories is an array of Strings containing
// the keys of the directories where the reference aReferencia
// should be classified. In case there where any previous
// related directories, the relationship is cleared before adding
// the new ones. Error checking removed for brevity's sake
//...
TgidDirectorioLocalHome aDirectorioHome = TgidDirectorioUtil.getLocalHome();
Collection referenceParents = aReferencia.getTgidDirectorios();
// RELATIONSHIP CLEARED
referenceParents.clear();
TgidDirectorioPK theParentPk;
for (int i = 0; i < parentDirectories.length; i++)
{
theParentPk = new TgidDirectorioPK(parentDirectories[i]);
TgidDirectorioLocal aDirectorio =
aDirectorioHome.findByPrimaryKey(theParentPk);
// NEW RELATED RECORD ADDED
referenceParents.add(aDirectorio);
}
//...
Another sample: Removing just one row of the relationship
A directory can have sub-directories and super-directories so it also has an N-M
relationship with itself. Here it is a piece of code where the relationship with
the children directories is modified:
// Removing a children directory
// Error checking removed
TgidDirectorioPK aDirectorioPK =
new TgidDirectorioPK(directoryCode);
TgidDirectorioPK childrenDirectorioPK =
new TgidDirectorioPK(childrenDirectoryCode);
TgidDirectorioLocalHome aDirectorioHome =
TgidDirectorioUtil.getLocalHome();
TgidDirectorioLocal aDirectorio =
aDirectorioHome.findByPrimaryKey(aDirectorioPK);
TgidDirectorioLocal childrenDirectorio =
aDirectorioHome.findByPrimaryKey(childrenDirectorioPK);
Collection childrenDirectories = aDirectorio.getChildrenTgidDirectorios();
// RELATED RECORD REMOVED
childrenDirectories.remove(childrenDirectorio);
//...
What I actually do is to generate XML from my EJBs, to be later processed by an
XSLT, so I don't need to pass value objects to the presentation logic. Anyway,
couldn't you use regular objects throughout your business logic and pass just
value objects to the struts UI classes? That way the relationships would be
handled by the session beans through regular objects and that way it works, at
least for me :).
I hope it helps,
D.
> Can I see your code that does this?
>
> I am using Struts for my UI. I want to keep the UI and EJB seperate so I
> have used Value Objects throughout.
> I can add them to the relationship just fine, but not remove them. So once I
> set a Contact as part of an Alert, they are _always_ part of that Alert. For
> beta testing I can work around this, but I can't go live like this.
>
>
>
> ---
> Thanks...
> Mick Knutson
> ---
--
This message was sent using Sake Mail, a web-based email tool from
Endymion Corporation. http://www.endymion.com/products/sakeCan I see your code that does this?I am using Struts for my UI. I want to keep the UI and EJB seperate so I have used Value Objects throughout.
I can add them to the relationship just fine, but not remove them. So once I set a Contact as part of an Alert, they are _always_ part of that Alert. For beta testing I can work around this, but I can't go live like this.
--- Thanks... Mick Knutson ---
From: Daniel Lopez <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [Xdoclet-user] updating a m-m value object? Date: Sat, 28 Jun 2003 18:24:08 +0200 (CEST)
Hi Mick,
I just joined the list so I have not followed the issue, but I'm using n-m
CM-relationships and I'm adding & removing relations through them without
problems. However, I'm not using Value Objects for that but the regular
Collections that are returned by the relationship methods. It might sound
obvious but have you tried that? Are you having problems just when doing so
through value objects? As I said, I'm not using them, just using Data objects
and not handling relationships through them.
Good luck,
D.
> Am I the only person trying to delete the 'n' side of m-n relationships?
> or is there just no person in the past 3 weeks of my asking willing to help
> me fix this issue?
> Can someone please help?
>
>
> I can't seem to figure out how to delete the m-n relationships. I can create
> them just fine, but when I try to call clear() on my VO, the values do not
> sem to get cleared, and they are not deleted from the relation table.
>
>
> ---
> Thanks...
> Mick Knutson
> ---
... snipped
-- This message was sent using Sake Mail, a web-based email tool from Endymion Corporation. http://www.endymion.com/products/sake << Originalmessage >>
_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus
------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01 _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
