Re: using template directives with anchor tags

Martin Diener <[email protected]>
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <[email protected]>
Hi,

I just started working with Barracuda, so please feel warned that the 
following hint may not be the most elegant or "right" solution for your 
question.
I run into the same problem last week. After a day try-and-error I figured 
out, that you can nest directives. My experiences with BLink, BTable and 
setName() had not been successfull. Maybe I tried it the wrong way. 

Here comes my (working) solution. (My html is generated. I removed lots of 
formating tags "by hand" for this posting ... maybe I removed to much ...)

<TABLE> 
  <TR class="Dir::Iterate_Start.MainScreenData 
Dir::Iterate_Next.MainScreenData"> 
    <TD><P><span 
class="Dir::Get_Data.MainScreenData.Project">primeProject</span></P></TD> 
    <TD><P><A HREF="../html/current.html" 
class="Dir::Get_Data.MainScreenData.DataSet"> 
           <span 
class="Dir::Get_Data.MainScreenData.CurrentDataSetName">Display 
Text</span></A></P></TD> 
  </TR> 
  <TR class="Dir::Iterate_Next.MainScreenData"> 
    <TD><P><span 
class="Dir::Get_Data.MainScreenData.Project">otherProject</span></P></TD> 
    <TD><P><A HREF="../html/currentshare.html" 
class="Dir::Get_Data.MainScreenData.DataSet"> 
            <span class="Dir::Get_Data.MainScreenData.CurrentDataSetName">Next 
Text</span></A></P></TD> 
  </TR> 
  <TR class="Dir::Iterate_End.MainScreenData Dir::Discard"> 
    <TD><P>..</P></TD> 
    <TD><P>..</P></TD> 
  </TR> 
</TABLE>

And here the corresponding java code snipplet:

	public Object getItem(String key) { 
		ViewContext vc = getViewContext(); 
		if (key.equals("Project")){ 
		 	return currentDataSetData.getProject(); 
		} else if (key.equals("DataSet")) { 
			String dataSetName = currentDataSetData.getDataSet(); 
			BAction link = new BAction(new GetDataSetData()); 
			//link.setName(dataSetName); 
			try { 				
link.setParam("project",URLEncoder.encode(currentDataSetData.getProject(),"ISO-8859-1")); 
link.setParam("dataSet",  URLEncoder.encode(currentDataSetData.getDataSet(),  
"ISO-8859-1")); 
				} catch (UnsupportedEncodingException e) { 
				logger.error("Unable to URLEncode (ISO-8859-1) in MainScreen.java"); 
				e.printStackTrace(); // ToDo: remove this line after testing method 
			} 
			return link; 
		} else if (key.equals("CurrentDataSetName")) { 
			return currentDataSetData.getDataSet(); 
		} else { 
			return super.getItem(key); 
		} 
	} 

Maybe this hint is useful for you.

Regards
Martin

On Monday 22 September 2003 22:57, [email protected] wrote:
> We need a way to use templates to take data from an iterative model and
> encapsulate it in an anchor tag. We tried using a BAction object, but that
> just ended up doing a toString() on it. Then we tried constructing the
> anchor tag ourselves, but it ends up getting URLEncoded somewhere... So,
> any ideas on how to use template directives with anchor tags?
>
> Thanks,
> Scott
> _______________________________________________
> Barracuda mailing list
> [email protected]
> http://barracudamvc.org/lists/listinfo/barracuda
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.