<%@ page import="com.novell.emframe.dev.eMFrameUtils,
                 org.jdom.Document,
                 org.jdom.Element,
                 java.util.Locale,
                 com.novell.emframe.dev.GlobalRegistry"%>
<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<iman:stringtable bundle="DevResources"/>
<iman:stringtable bundle="FwResources"/>

<HTML>
<HEAD>
   <iman:eMFrameScripts/>
   <iman:stylesheet/>

   <SCRIPT>
      function onExit()
      {
         document.form.submit();
      }
   </SCRIPT>
</HEAD>

<BODY>
<FORM name="form">

   <INPUT type="hidden" name="taskId" value="<c:out value="${taskId}"/>">
   <INPUT type="hidden" name="nextState" value="save">

   <iman:taskHeader titleKey="PrimaryViewManagment.title" titleBundle="FwResources"/><BR>

   <SPAN class="smalltext2d" colspan="3"><iman:string key="SetPrimaryView.instructions"/></SPAN>

   <TABLE>
      <TR>
         <TD colspan="3">&nbsp;</TD>
      </TR>

      <c:forEach items="${views}" var="item">
         <TR>
            <%
               String id = (String)pageContext.findAttribute("item");
               String primaryId = (String)pageContext.findAttribute("primaryViewId");

               Document doc = GlobalRegistry.getPluginDocument(id);
               Element root = doc.getRootElement();

               Locale locale = com.novell.emframe.fw.FwUtils.getCurrentLocale(session);
               String key = root.getChildTextTrim("header-hint-text-key");
               String bundle = root.getChildTextTrim("resource-properties-file");
               String title = eMFrameUtils.getLocalizedString(bundle, key, locale);

               String canBeDefault = root.getChildTextTrim("can-be-default");
               if(canBeDefault==null || !canBeDefault.equals("false")){
            %>
            <TD style="vertical-align: top"> <INPUT type="radio" name="primaryView" value="<c:out value="${item}"/>" <% if(id.equals(primaryId)) out.print("checked");%> ></TD>
            <TD style="vertical-align: top"> <IMG src="/nps/portal<%= root.getChildTextTrim("header-normal-icon")%>.png" border="0" ></TD>
            <TD style="vertical-align: top"> <%= title %></TD>
            <% } %>
         </TR>
      </c:forEach>
   </TABLE>


   <BR>
   <iman:bar/>
   <iman:button key="OK" onClick="onExit()"/>
   <iman:cancelBtn/>

</FORM>
</BODY>
</HTML>