Skip to main content

Dynamic data with Tabbed view

1 reply [Last post]
albees
Offline
Joined: 2008-01-07
Points: 0

Hi All,

How can I dynamically display tabs in tabbed view. My widget is

Here the tab 1 content is coming from a java bean with name content. I want the tab 1 to be visible only if content.tab1 is not null. Please help.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gmurray71
Offline
Joined: 2003-07-31
Points: 0

Hi,

The best way to solve this is to use a service to load the tab data.

The service (a JSP page) can render the :

{items:[
{label : 'Tab 1', content : '${content.tab1}', selected : true},
{id : 'bar', label : 'My Tab 2', include : 'test.jsp ', lazyLoad : true },
{label : 'My Tab 3', content : 'More Content'}
]
}

Using conditional logic (even JSTL) based on the state of the data.

Here is a page from our webtop.jsp which uses JPA

<%
List list = em.createNamedQuery("Widget.findAll").getResultList();

out.println("{ items : [");

for (int i=0; i
Widget w = list.get(i);
String value = w.getWidgetValue();
String include = w.getWidgetInclude();
Boolean iframe = w.getWidgetIframe();

out.print("{\"id\":\"" + w.getWidgetId() + "\", " +
"\"label\":\"" + w.getWidgetLabel() + "\"," +
"\"description\":\"" + w.getWidgetDescription() + "\",");

if (iframe != null) {
out.println("\"iframe\":" + iframe + ",\n");
}
out.print("\"startHeight\":" + w.getWidgetstartHeight() +
",\"imgSrc\":\"" + w.getWidgetIcon() + "\"\n" +
"}");

if (i < list.size()-1)
out.println(",");
else
out.println();
}
out.println("] }");
%>

Calling your service will be something like:

service="mytabs.jsp" />

For a little more see:

http://weblogs.java.net/blog/carlavmott/archive/2007/06/making_jmaki_se....

Let me know if you still have trouble.

-Greg