Ignore:
Timestamp:
2002-10-04T13:21:34+12:00 (22 years ago)
Author:
kjdon
Message:

library names are now done dynamically, not specified in the applet info at the service end. the info is added by the applet action if needed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/AppletAction.java

    r3441 r3443  
    55// XML classes
    66import org.w3c.dom.Node;
     7import org.w3c.dom.NodeList;
    78import org.w3c.dom.Document;
    89import org.w3c.dom.Element;
     
    7879       
    7980        page.appendChild(doc_.importNode(request, true));
     81
    8082        // add in the applet info
    81        
    82         //page.appendChild(doc_.importNode(GSXML.getNodeByPath(mr_response, "response/service/applet"), true));
    83         page.appendChild(doc_.importNode(GSXML.getNodeByPath(mr_response, "response/service/applet"), true));
     83        Element app_desc = (Element)doc_.importNode(GSXML.getNodeByPath(mr_response, "response/service/applet"), true);
     84        // must look through the applet description and see if there is a param called library. if so, add the value to be the current library name
     85
     86        addLibraryName(app_desc, config_.library_name_);
     87        page.appendChild(app_desc);
    8488        return transformer_.transform(stylesheet, page);
    8589    }
     
    111115    }
    112116    }
     117
     118    /** this method looks through the PARAMs of the applet description for
     119     * one with the name 'library'. If its found, it sets the value to be
     120     * library_name
     121     */
     122    protected void addLibraryName(Element description, String library_name) {
     123
     124    Node child = description.getFirstChild();
     125    while (child != null) {
     126        if (child.getNodeType() == Node.ELEMENT_NODE) {
     127        String param = child.getNodeName();
     128        if (param.equals("PARAM")||param.equals("param")) {
     129            String name = ((Element)child).getAttribute("NAME");
     130            if (name == null || name.equals("")) {
     131            // somethings wrong!!
     132            } else if (name.equals("library")) {
     133            ((Element)child).setAttribute("VALUE", library_name);
     134            break;
     135            }
     136           
     137        }
     138        }
     139        child = child.getNextSibling();
     140    }
     141    }
     142   
    113143}
Note: See TracChangeset for help on using the changeset viewer.