Changeset 23333


Ignore:
Timestamp:
2010-11-16T17:12:05+13:00 (12 years ago)
Author:
sjb48
Message:

Working on saving the format statement. Currently have a button that calls the system action and returns some html. Working on system.xsl but need to get the format string from String to XML. I have found out that HTML is not necessarily valid XML.

Location:
main/trunk/greenstone3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/SystemAction.java

    r16688 r23333  
    1212import java.io.File;
    1313import java.util.HashMap;
     14import java.util.*;
     15import java.io.StringReader;
     16import org.xml.sax.InputSource;
     17import javax.xml.parsers.DocumentBuilder;
     18import javax.xml.parsers.DocumentBuilderFactory;
    1419
    1520import org.apache.log4j.*;
     
    5560        String info = (String)params.get(GSParams.SYSTEM_SUBSET);
    5661        system.setAttribute(GSXML.SYSTEM_SUBSET_ATT, info);
    57    
     62    }
     63    else if(subaction.equals("s")) { // save format statement
     64         logger.error("Initiate save");
     65         String format_string = (String)params.get("data");
     66         logger.error("data="+format_string);
     67         Iterator it = params.keySet().iterator();
     68         while(it.hasNext())
     69         {
     70            logger.error("Param: "+it.next());
     71         } 
     72        Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     73
     74        try {
     75            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
     76            DocumentBuilder builder = factory.newDocumentBuilder();
     77            InputSource is = new InputSource( new StringReader( format_string ) );
     78            Document d = builder.parse( is );
     79            page_response.appendChild(d);
     80        }
     81        catch( Exception ex ) {
     82            logger.error("There was an exception "+ex);
     83        }
     84
     85        //Element child = this.doc.createElement("div"); //format_string);
     86        //Node text = this.doc.createTextNode(format_string); //"<h1>Hi there and greetings!</h1>");
     87        //child.innerHTML = "<h1>Hi there and greetings!</h1>";
     88        //child.setNodeValue(format_string);
     89        //child.appendChild(text);
     90        result.appendChild(page_response);
     91        return result;
    5892    } else {
    5993        String name = (String)params.get(GSParams.SYSTEM_MODULE_NAME);
  • main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js

    r23312 r23333  
    77{
    88
    9     var formatStatement = document.getElementById('formatStatement');
    10     console.log(formatStatement);
    11     if(formatStatement.hasChildNodes())
    12     {
    13         var formatstring = traverse(formatStatement, "");
    14         console.log(formatstring);
     9    var formatStatement = document.getElementById('formatStatement').innerHTML;
     10    //console.log(formatStatement);
     11
     12    //var myurl = 'http://localhost:8080/greenstone3/format?a=s&sa=s&t='+formatStatement;
     13
     14    //jQuery.post( url, [ data ], [ success(data, textStatus, XMLHttpRequest) ], [ dataType ] )
     15
     16    $.post("http://localhost:8080/greenstone3/format?a=s&sa=s", {data: formatStatement}, function(data) {
     17        $('.result').innerHTML = data; //html(data);
     18        console.log("Success, we have received data");
     19        console.log(data);
     20        }, 'html');
     21
     22/*
     23    $.ajax({
     24        type: "POST",
     25        url: "http://localhost:8080/greenstone3/format?a=s&sa=s",
     26        data: formatStatement,
     27        processData: false,
     28        success: function(data) {
     29            //$('.result').html(data);
     30            console.log("Success, we have received data");
     31            //console.log(data);
     32        }
     33     });
     34*/
     35    /*
     36    $.ajax({
     37        url: myurl,
     38        success: function(data) {
     39            //$('.result').html(data);
     40            console.log("Success, we have received data");
     41            console.log(data);
     42        }
     43    });
     44    */
     45    //if(formatStatement.hasChildNodes())
     46    //{
     47        //var formatstring = traverse(formatStatement, "");
     48        //console.log(formatstring);
    1549
    1650        // var children = $(formatStatement).children('div');
     
    3569        }
    3670        */
    37     }
     71    //}
    3872}
    3973
  • main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl

    r23312 r23333  
    262262                    </script>
    263263
     264                    <div id="result">
     265                    Here
     266                    </div>
     267
    264268                    <div id="gs_footer">
    265269                        <xsl:call-template name="poweredByGS3TextBar"/>
  • main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl

    r23312 r23333  
    236236            <xsl:variable name="mode">
    237237                <xsl:choose>
    238                     <xsl:when test="not(@mode)">MODE=<input class="mode" type="text" name="rawtextinput" size="10" value="vertical"/></xsl:when>
    239                     <xsl:otherwise>MODE=<input class="mode" type="text" name="rawtextinput" size="10" value="{@mode}"/></xsl:otherwise>
     238                    <xsl:when test="not(@mode)">MODE=<input class="mode" type="text" name="rawtextinput" size="10" value="vertical"></input></xsl:when>
     239                    <xsl:otherwise>MODE=<input class="mode" type="text" name="rawtextinput" size="10" value="{@mode}"></input></xsl:otherwise>
    240240                </xsl:choose>
    241241            </xsl:variable>
    242242   
    243             <table class="header"><tbody><tr><td class="header">MATCH=<input class="match" type="text" name="rawtextinput" size="10" value="{@match}"/></td><td class="header"><xsl:copy-of select="$mode"/></td><td class="header"><a href="#" class="minmax ui-icon ui-icon-plusthick" title="Click me to expand">[+]</a></td><td class="header"><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table>
     243            <table class="header"><tbody><tr><td class="header">MATCH=<input class="match" type="text" name="rawtextinput" size="10" value="{@match}"></input></td><td class="header"><xsl:copy-of select="$mode"/></td><td class="header"><a href="#" class="minmax ui-icon ui-icon-plusthick" title="Click me to expand">[+]</a></td><td class="header"><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table>
    244244
    245245                <table class="table" border="1">
     
    356356        <div class="block leaf gsf_text" title="gsf:text">
    357357                <xsl:variable name="rawtext"><xsl:value-of select="."/></xsl:variable>
    358                 <table class="header"><tbody><tr><td class="header"><input type="text" name="rawtextinput" size="10" value="{$rawtext}"/></td><td class="header"><a href="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table>
     358                <table class="header"><tbody><tr><td class="header"><input type="text" name="rawtextinput" size="10" value="{$rawtext}"></input></td><td class="header"><a href="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table>
    359359        </div>
    360360    </xsl:template>
Note: See TracChangeset for help on using the changeset viewer.