Discussion:
[Middlegen-user] how to make a create method with parameters
Andreas Langman
2002-04-05 12:06:09 UTC
Permalink
Hello,

i want to generate a create Method looking like this:

public java.lang.Integer ejbCreate(int field1, int field2, int field3)
throws javax.ejb.CreateException

but the following code in entity-cmp.j creates an superfluous "," after
field3. Is there a way to remove it?

public java.lang.Integer
ejbCreate(<XDtMg:forAllFields><XDtMg:ifIsNotPkOrFk><XDtMg:propertyType/>
<XDtMg:propertyName/>, </XDtMg:ifIsNotPkOrFk></XDtMg:forAllFields>)
throws javax.ejb.CreateException


Thanks,

Andreas Langmann
a***@netcom.no
2002-04-05 12:31:17 UTC
Permalink
Hi Andreas,

I presume:
-You're using the latest CVS version.
-You're modifying entity-cmp.j to suit your own needs.

What you need to do is to define your blaBlaEjbCreateSignature() method
in EntityCMPTagsHandler. Look at ejbCreateSignature() for inspiration.

Then in your template: ejbCreate(<XDtMg:blaBlaEjbCreateSignature/>)

It's easier to perform the should-there-be-a-comma-or-not logic in java
than in the template.

A second solution would be to define a body tag in MiddlegenTagsHandler
� la

public void ifNotLastField(String template) throws XDocletException {
if( _currentProperty != _table.getField(_table.getFieldCount() - 1) )
// the current field is not the last.
generate(template);
}
}

And then

public java.lang.Integer
ejbCreate
(<XDtMg:forAllFields><XDtMg:ifIsNotPkOrFk><XDtMg:propertyType/>
<XDtMg:propertyName/><XDtMg:ifNotLastField>,
</XDtMg:ifNotLastField></XDtMg:ifIsNotPkOrFk></XDtMg:forAllFields>)
throws javax.ejb.CreateException

But the 1st solution seems better to me.

Aslak

----- Original Message -----
From: Andreas Langman <***@isb-ag.de>
Date: Friday, April 5, 2002 4:05 pm
Subject: [Middlegen-user] how to make a create method with parameters
Post by Andreas Langman
Hello,
public java.lang.Integer ejbCreate(int field1, int field2, int
field3) throws javax.ejb.CreateException
but the following code in entity-cmp.j creates an superfluous ","
after
field3. Is there a way to remove it?
public java.lang.Integer
ejbCreate
(<XDtMg:forAllFields><XDtMg:ifIsNotPkOrFk><XDtMg:propertyType/>
Post by Andreas Langman
<XDtMg:propertyName/>, </XDtMg:ifIsNotPkOrFk></XDtMg:forAllFields>)
throws javax.ejb.CreateException
Thanks,
Andreas Langmann
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Loading...