<%@ page language="java" import="java.util.*,java.sql.*,java.beans.*,iDSS.*,iDSS.utils.*,iDSS.webBeans.*,iDSS.beans.*,iDSS.beans2.*,iDSS.grids.*,iDSS.tidalData.*"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
	<TITLE><%=IDSSAppConstants.programTitle%></TITLE>

<META HTTP-EQUIV="KEYWORDS" CONTENT="internet-based, DSS, decision support system, Java, Enterprise edition, J2EE">
<META HTTP-EQUIV="DESCRIPTION" CONTENT="">		
</HEAD>

<jsp:useBean id="gridManagerJBean" scope="session" class="iDSS.beans2.GridManagerJBean"/>
<jsp:useBean id="modelSetupControllerJBean" scope="session" class="iDSS.beans2.ModelSetupControllerJBean"/>
<jsp:useBean id="statusJBean" scope="session" class="iDSS.beans2.StatusJBean"/>
<jsp:useBean id="tidalStationsLocalJBean" scope="session" class="iDSS.beans2.TidalStationsLocalJBean"/>
<jsp:useBean id="dataManagerJBean" scope="session" class="iDSS.beans2.DataManagerJBean"/>
<jsp:useBean id="tidalModelsListJBean" scope="session" class="iDSS.beans2.TidalModelsListJBean"/>


<body>
<h2><%=IDSSAppConstants.tidalModelsList%></h2>



<%

    String actionButtonName = request.getParameter(IDSSAppConstants.acceptButtonText);

    gridManagerJBean.removePropertyChangeListener(modelSetupControllerJBean);
    gridManagerJBean.addPropertyChangeListener(modelSetupControllerJBean);
    statusJBean = modelSetupControllerJBean.getStatusBean();
    tidalStationsLocalJBean.removePropertyChangeListener(dataManagerJBean);
    tidalStationsLocalJBean.addPropertyChangeListener(dataManagerJBean);
    dataManagerJBean.removePropertyChangeListener(tidalModelsListJBean);
    dataManagerJBean.addPropertyChangeListener(tidalModelsListJBean);

    Hashtable tidalModels = tidalModelsListJBean.getTidalModelHashtable();


    if(actionButtonName != null) {

%>
        <p>The button you clicked is <%=actionButtonName%>. </p>
<%


        if (actionButtonName.equals(IDSSAppConstants.acceptButtonText)) {

            Enumeration tmKeys = tidalModels.keys();


            while(tmKeys.hasMoreElements()) {

                String tmKey = (String)tmKeys.nextElement();
                String wt = request.getParameter(tmKey);
                TidalModel tm = (TidalModel)tidalModels.get(tmKey);
                int wtInt = Integer.parseInt(wt);
                tm.setWeightage(wtInt);

            } //while(tmKeys.hasMoreElements())

            statusJBean.setTidalModels(String.valueOf(tidalModels.size()));
            modelSetupControllerJBean.setAllTidalModels(tidalModels);

        } //if (actionButtonName.equals(IDSSAppConstants.acceptButtonText))
    } //if(actionButtonName != null)



%>








<form method=get>


    <table width="50%" border="0" VSPACE="5" HSPACE="5" CELLPADDING="5">
        <tr BGCOLOR="#C0C0C0">
            <th width="40%">Tidal Model</th>
            <th width="10%">Rel Wt</th>
        </tr>

    <%


        Enumeration tmKeys = tidalModels.keys();

        while(tmKeys.hasMoreElements()) {

            String tmKey = (String)tmKeys.nextElement();
            TidalModel tm = (TidalModel)tidalModels.get(tmKey);
            int wtInt = tm.getWeightage();
            String wt = String.valueOf(wtInt);

    %>

            <tr BGCOLOR="#80FFFF">
                <td>
                    <%=tmKey%>
                </td>


                <td>
                    <select name="<%=tmKey%>" size="1">

                        <%
                            for(int i=0;i<11;i++) {
                                if(i == wtInt) {
                        %>

                                    <option value="<%=i%>" selected><%=i%></option>

                        <%
                                } //if(i == wtInt)

                                else {

                        %>
                                    <option value="<%=i%>"><%=i%></option>
                        <%


                                } //else
                            } //for(int i=0;i<11;i++)
                        %>

                    </select>
            </td>


            </tr>

    <%
        } //while(tmKeys.hasMoreElements())
    %>

    </table>


    <input type=submit value="<%=IDSSAppConstants.acceptButtonText%>" name="<%=IDSSAppConstants.acceptButtonText%>">

</form>






<p>test of the content of tidalModelsHashtable</p>






<%

    tmKeys = tidalModels.keys();

    while(tmKeys.hasMoreElements()) {

        String tmKey = (String)tmKeys.nextElement();
        TidalModel tm = (TidalModel)tidalModels.get(tmKey);

        %>
            <p>tmKey : <%=tmKey%></p>
            <p>tm.getWeightage() : <%=tm.getWeightage()%></p>
        <%

    } //while(tmKeys.hasMoreElements())

%>





</body>

</HTML>

