Reputation: 1
We have application in Tiles2 where we have tiles definition tag having bean in the put-list-attribute and works well, but not able to migrate those for Tiles 3 compatible one. Can anyone guide us,
sample code ...
<definition name=".tabs.resource.list" extends=".tabs.resource">
<put-attribute name="selectedIndex" value="0" />
<put-attribute name="resourceType" value="1" />
<put-list-attribute name="tabList">
<bean classtype="org.test.sample.ui.util.Tab">
<set-property property="value" value="Tab1" />
<set-property property="link" value="currentHealthTab1listVisibility.action" />
<set-property property="mode" value="currentHealth" />
<set-property property="height" value="21" />
<set-property property="width" value="102" />
</bean>
<bean classtype="org.test.sample.ui.util.Tab">
<set-property property="value" value="Tab2" />
<set-property property="link" value="viewlistTab2listVisibility.action" />
<set-property property="mode" value="view" />
<set-property property="height" value="21" />
<set-property property="width" value="102" />
</bean>
</put-list-attribute>
</definition>`
org.test.sample.ui.util.Tab is override for simplemenuitem class
Upvotes: 0
Views: 221
Reputation: 1
As beans for Menu Item is removed in latest version of tiles, We will have to create servlet class and map to the jsp page uses those attributes {in the above question which jsp pointed in extends=".tabs.resource" / jsp page in the definition} in web.xml and set the attribute in the class we can set up the list attribute and include the servlet response as below:
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.test.sample.ui.util.Tab;
public class ControlTabNG extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException{
List<Tab> ControlTabNGtablist = new ArrayList<Tab>();
Tab ObjTab1 = new Tab();
ObjTab1.setValue("Tab1");
ObjTab1.setLink("viewlistTab1listVisibility.action");
ObjTab1.setMode("View");
ObjTab1.setHeight(21);
ObjTab1.setWidth(101);
Tab ObjTab2 = new Tab();
ObjTab2.setValue("Tab2");
ObjTab2.setLink("viewlistTab2listVisibility.action");
ObjTab2.setMode("View");
ObjTab2.setHeight(21);
ObjTab2.setWidth(101);
ControlTabNGtablist.add(ObjTab1);
ControlTabNGtablist.add(ObjTab2);
request.setAttribute("tabList", ControlTabNGtablist);
try {
RequestDispatcher rd=request.getRequestDispatcher("/simplemenuitem/SampleTabNG.jsp");
rd.include( request, response);
} catch (ServletException e) {
e.printStackTrace();
}
`
Upvotes: 0