Skip to main content

passing attributes in nested tiles

Tiles is a great framework to organize site content by constructing a page using multiple tiles. It allows reuse and customization of site content. I ran into a problem of making tiles attribute visible to a nested tile. The attributes defined in tiles definitions are defined in tiles scope and hence only available to the tile associated with the definition. In order to make the attribute available to nested tiles, pass the attribute as follows;

<tiles:insert attribute="header" ignore="true">
<tiles:put name="title" beanName="title" beanScope="tile"/>
</tiles:insert>

If there is a need to access the attribute in struts bean tags or JSTL use <tiles:useAttribute/> or <tiles:importAttribute/> tags in jsp to access the attribute as follows;

<tiles:useAttribute name="title" />

You can now access the value of title attribute using struts bean tag <bean:write name="title" /> or using JSTL as ${title}

For more detailed explanation look at a sample chapter Developing applications with tiles from the book Struts in Action.

More advanced tips and tricks for tiles can be found in Master the Tiles framework and The Advanced Fratures.

Comments

Popular posts from this blog

Creating no-reply@domain.com account in Postfix

If you wanted to send emails to users but did not want to receive any replies to the email, you would need to setup a no-reply@domain.com email account. These kind of email ids are useful when sending emails containing forgotten passwords or activation code. Below are the steps for creating such account in Postfix. 1. Identify the file containing alias for Postfix First, make sure the following line in the ALIAS DATABASE section of the /etc/postfix/main.cf is NOT commented out: alias_maps = hash:/etc/aliases 2. Create an alias that redirects messages to /dev/null Edit /etc/aliases and add following entry devnull: /dev/null 3. Create a virtual email id Edit /etc/postfix/virtual and add following entry no-reply@domain.com devnull 4. refresh postfix alias and postfix cache Execute following commands. (You may require root privileges) > newaliases > postfix reload

jupyter notebook execution error: "http://localhost:8889/tree?token=xxx" doesn’t understand the “open location” message

I got this error when I tried to launch jupyter notebook on a mac. It is not a fatal error. I could still go to browser directly and copy/paste the url manually. The error indicates that when the command automatically tried to launch a browser, it couldn't find the default browser in jupyter configuration file. The easy fix is to specify the browser. Here are the steps to do so; 1.   Open ~/.jupyter/jupyter_notebook_config.py in an editor.       If the file does not exist then you can create a default config file by typing the following command;       jupyter notebook --generate-config 2. Search for a word "browser" to locate a following line.     #c.NotebookApp.browser = ''     By default it is commented. You can uncomment it and use one of the following values depending on your browser preference.     # set default browser to chrome     c.NotebookApp.browser = 'chrome'     ...

Firefox 401 - Unauthorized: Access is denied due to invalid credentials

I was getting this error in Firefox when I tried loading our company intranet site. Chrome was able to log me in fine. I found a solution on Mozilla support forum. See the image below for a fix. Set the value to true and then try loading the page again. That fixed the problem for me. Next time I visited the site it prompted me to enter username and password.