Hi Christian,
Christian Pekeler wrote:
[...]
I would like to use these new features, but there is no example and I
can't get it to work:
<$if className in ('"NSData", "NSTimestamp")$>...
This expression is accepted by EOGenerator, but it doesn't evaluate
to "true" when "className" variable is "NSData" or "NSTimestamp". Is
there someone that knows how to define an array and how to use it
with the new "in" and "notin" operators?
I don't know how to define an array. But I've recently extended my
template to only import required packages using the 'in' operator.
Sounds like you might be trying to accomplish the same.
Exactly.
<$if [EMAIL PROTECTED] > 0 or [EMAIL PROTECTED] >
0$>import com.webobjects.eocontrol.*;<$endif$><$if 'NSTimestamp' in
classAttributes.javaValueClassName or [EMAIL PROTECTED]
> 0$>
import com.webobjects.foundation.*;<$endif$><$if 'BigDecimal' in
classAttributes.javaValueClassName$>
import java.math.*;<$endif$>
Thanks! With your hint, I've finally found the way to make it works! I
was trying to use the "in" clause with an array of a single object,
i.e.:
<$if className in ("BigDecimal")$>
This kind of construction is not supported (bug?). The "==" operator
must be used instead:
<$if className == "BigDecimal"$>
Below is a working example. It would be far easier to manage imports if
it could be possible to join arrays and filter duplicates with
EOGenerator/MiscMerge:
...
<$set previousClassName = ""
$><$foreach className
[EMAIL PROTECTED]
y do
$><$if className != previousClassName
$><$set previousClassName = className
$><$if className == "EOEnterpriseObject"
$>import com.webobjects.eocontrol.<$className$>;
<$else
$>import <$className$>;
<$endif
$><$endif
$><$endforeach do
$><$if classToManyRelationships.count > 0
$>import com.webobjects.foundation.NSArray;
<$endif
$><$foreach className
[EMAIL PROTECTED] do
$><$if className != previousClassName$><$set previousClassName =
className
$><$if (className == "NSArray" and classToManyRelationships.count ==
0) or (className in ("NSData", "NSDictionary", "NSTimestamp"))
$>import com.webobjects.foundation.<$className$>;
<$elseif className == "BigDecimal"
$><import java.math.<$className$>;
<$else
$><$endif
$><$endif
$><$endforeach do
$>
...
Kind regards,
--
Francis Labrie
Saint-Bruno-de-Montarville, Quebec, Canada
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]