commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From texe...@free.fr
Subject [jelly] Create hierarchical jexl expression.
Date Sun, 04 Jan 2004 00:15:05 GMT


Hello.
I want to create hierachical expression to access at every level.
An example would says it better :
<?xml version="1.0"?>
<j:jelly xmlns:j="jelly:core" xmlns:s="jelly:myPackage.jelly.SamaTagLibrary">
     <s:configuration>
	<s:declaration name="declaration"> 
		<s:domain name="referential">
			<s:entity name="personne">
                            <s:attribute name="name"/>
                            <s:attribute name="forname"/>
                        <s:entity>
		</s:domain>	
		<s:domain name="ldap">
			<s:entity name="person"/>
                            <s:attribute name="surname"/>
                            <s:attribute name="givenname"/>
                        <s:entity>
		</s:domain>
	</s:declaration>
     </s:configuration>
</j:jelly>

After the <declaration> tag I would access to some data
with expression like :
${referential.personne.name}
${referential.personne.forname}
${ldap.person.surname}	
 but also 
${ldap.person}	to designate the set of attribute under 
//s:domaine[@name='ldap']/s:entity[@name='person']

I have first try this

DomainTag.dotTag ==>
...
			HashMap myHashMap = new HashMap();
			JellyContext myContext = this.getContext();
			myContext.setVariable(getName(), myHashMap);
...

and EntityTag.doTag ==>
...
			HashMap domainMap = (HashMap)( this.getContext
().getVariable(((SamaDomainTag)domainTag).getName()) );
			if ( domainMap != null )
			{
				if (domainMap.containsKey(getName()) == true )
				{
					throw new JellyTagException
("Entity "+getName()+" already exists !"); 
				}
				else
				{
					domainMap.put(getName(),this);
				}
			}
...

but it's no really pretty.


If I put for each of them
this.getContext().setVariable(getName(), this);

do the Expression evalutation scan from parent to child contexts
to evaluate ${domain.entity.attribute} ?

Can somebody explain "softly" :) the context hierachie between nested elements ?

Thanks a lot :)

PS : setExport(true) implies NullPointerException, and with the first try it 
works better without.
There's something I don't understood with JellyContext ?

Marc DeXeT (at home)




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message