Project

General

Profile

« Previous | Next » 

Revision 3542

add ability to retrieve response data using datamanager lib (note that this requires both the datamanager.jar and firstMetacatIntegration.jar from /eml and /first modules respectively...)
yes, this is more ajax...and still mostly Proof Of Concept-ish

View differences:

lib/style/skins/first/assessmentQuery.jsp
1
<%@page import="java.sql.ResultSet"%>
2
<%@page import="edu.ucsb.nceas.first.metacat.client.AssessmentQuery"%>
3
<%@page import="java.util.*"%>
4
<%
5

  
6
String[] docids = request.getParameterValues("docids");
7

  
8
if (docids != null && docids.length > 0) {
9

  
10
	List assessmentDocIds = Arrays.asList(docids);
11
	
12
	//make a title
13
	String tableTitle = "Showing data for ";
14
	for (int i=0; i<docids.length; i++) {
15
		tableTitle += docids[i];
16
		tableTitle +=", ";
17
	}
18
	tableTitle = tableTitle.substring(0, tableTitle.length()-2);
19
	
20
	//AssessmentQuery.testEcogrid("edml.4.5");
21
	ResultSet rs = AssessmentQuery.selectResponseData(assessmentDocIds);
22
	int numColumns = rs.getMetaData().getColumnCount();
23
%>
24

  
25
<!-- <h3><%=tableTitle %></h3> -->
26

  
27
<table>
28
<!-- 
29
<tr>
30
	<th colspan="<%=numColumns %>"><%=tableTitle %></th>
31
</tr>
32
-->
33
<tr>
34
<% for (int i=1; i<=numColumns; i++) { %>
35
	<th><%=rs.getMetaData().getColumnName(i) %></th>
36
<% } %>
37
</tr>
38
<%
39
while (rs.next()) {
40
	//System.out.println("rs:" + rs.getInt(1));
41
%>
42
	<tr>
43
<% for (int i=1; i<=numColumns; i++) { %>
44
		<td><%=rs.getInt(i) %></td>
45
<% } %>		
46
	</tr> 
47
<% 
48
} 
49
%>
50
</table>
51

  
52
<%}//end if %>
0 53

  
lib/style/skins/first/first-assessment-resultset.xsl
37 37
	<xsl:template match="/">
38 38
		<script language="JavaScript">
39 39
          <![CDATA[
40
          submitform = function(action,form_ref) {
40
          submitform = function(action,docid,form_ref) {
41 41
              form_ref.action.value=action;
42
              form_ref.docid.value=docid;
42 43
              form_ref.sessionid.value="]]><xsl:value-of select="$sessid" /><![CDATA[";
43 44
              //form_ref.qformat.value="]]><xsl:value-of select="$qformat" /><![CDATA[";
44 45
              form_ref.submit();
45 46
          }
46

  
47
          setSelect = function(form_ref, checkBoxName, checked) {
48
              var formElements = form_ref.elements;
49
              for (var i=0; i<formElements.length; i++) {
50
              	var myElement = formElements[i];
51
              	if (myElement.name == checkBoxName) {
52
              		myElement.checked = checked;
53
              	}
54
              }
55
          }    
47 56
          ]]>
48 57
        </script>
58
        <script type="text/javascript" language="Javascript">
59
			<![CDATA[
60
			getResponseData = function(docid, divId) {
61
				var styleURL = "/knb/style/skins/first";
62
				styleURL += "/assessmentQuery.jsp";
63
																				
64
				//alert("calling ajax: " + styleURL);
65
				//alert("docid: " + docid);
66
				
67
				var myUpdate = new Ajax.Updater(
68
					divId,
69
					styleURL,
70
					{	method: 'post',
71
						parameters: { docids: docid},
72
						//parameters: $('responseDataSearch').serialize(true),
73
						evalScripts: true, 
74
						//onSuccess: function(transport) {alert('success: ' + transport.status);},
75
						onFailure: function(transport) {alert('failure making ajax call');}
76
					 });
77
					 
78
				Element.show(divId);					
79
				//alert("done calling response ajax");
80
			}
81
			getMergedResponseData = function(formId,divId) {
82
				var styleURL = "/knb/style/skins/first";
83
				styleURL += "/assessmentQuery.jsp";
84
																				
85
				//alert("calling ajax: " + styleURL);
86
				//alert("docid: " + docid);
87
				
88
				var myUpdate = new Ajax.Updater(
89
					divId,
90
					styleURL,
91
					{	method: 'post',
92
						//parameters: { docid: docid},
93
						parameters: $(formId).serialize(true),
94
						evalScripts: true, 
95
						//onSuccess: function(transport) {alert('success: ' + transport.status);},
96
						onFailure: function(transport) {alert('failure making ajax call');}
97
					 });
98
					 
99
				Element.show(divId);					
100
				//alert("done calling response ajax");
101
			}
102
			hideDiv = function(divId) {
103
				Element.hide(divId);
104
			}
105
		 ]]>	
106
		</script>
49 107
        
50 108
		<p class="emphasis"><xsl:number value="count(resultset/document)" /> found</p>      
51 109
      
......
54 112

  
55 113
		<xsl:if test="count(resultset/document) &gt; 0">
56 114

  
115
			<form action="/knb/metacat" method="POST" id="assessmentForm" name="assessmentForm">
116
				<input type="hidden" name="qformat" value="first" />
117
				<input type="hidden" name="sessionid" />
118
				<input type="hidden" name="action" value="read" />
119
				<input type="hidden" name="docid" />
120
				
121
				<br/>
122
				Select:
123
				<a>
124
					<xsl:attribute name="href">javascript:setSelect(document.assessmentForm, 'docids', true)</xsl:attribute>
125
					<xsl:text>All</xsl:text>
126
				</a>
127
				/
128
				<a>
129
					<xsl:attribute name="href">javascript:setSelect(document.assessmentForm, 'docids', false)</xsl:attribute>
130
					<xsl:text>None</xsl:text>
131
				</a>
132
				<br/>
133
				Actions:
134
				<a>
135
					<xsl:attribute name="href">javascript:getMergedResponseData('assessmentForm','mergedResponseData')</xsl:attribute>
136
					<xsl:text>Merge Selected</xsl:text>
137
				</a>
138
				/
139
				<a>
140
					<xsl:attribute name="href">javascript:hideDiv('mergedResponseData')</xsl:attribute>
141
					<xsl:text>Hide</xsl:text>
142
				</a>
143
				<br/>
144
				<div id="mergedResponseData"/>
145
				<br/>
146
				
57 147
			<table width="95%" align="left" border="0" cellpadding="0"
58 148
				cellspacing="0">
59 149
				<tr>
......
76 166

  
77 167
				<xsl:for-each select="resultset/document">
78 168
					<xsl:sort select="./param[@name='assessment/@assessmentId']" />
169
					<xsl:variable name="divId">
170
						<xsl:text>ajaxDiv</xsl:text><xsl:value-of select="./docid" />
171
					</xsl:variable>
79 172
					<tr valign="top" class="subpanel">
80 173
						<xsl:attribute name="class">
81
               <xsl:choose>
82
                 <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
83
                 <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
84
               </xsl:choose>
85
             </xsl:attribute>
174
			               <xsl:choose>
175
			                 <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
176
			                 <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
177
			               </xsl:choose>
178
			             </xsl:attribute>
86 179

  
87 180
						<td class="text_plain">
88
							<form action="/knb/metacat" method="POST">
89
								<xsl:attribute name="name">
90
                   <xsl:value-of
91
										select="translate(./docid, '()-.', '____')" />
92
                 </xsl:attribute>
93

  
94
								<input type="hidden" name="qformat" value="first" />
95
								<input type="hidden" name="sessionid" />
96
								<xsl:if
97
									test="$enableediting = 'true'">
98
									<input type="hidden"
99
										name="enableediting" value="{$enableediting}" />
100
								</xsl:if>
101
								<input type="hidden" name="action"
102
									value="read" />
103
								<input type="hidden" name="docid">
104
									<xsl:attribute name="value">
105
                     <xsl:value-of select="./docid" />
106
                   </xsl:attribute>
107
								</input>
108
								<xsl:for-each select="./relation">
109
									<input type="hidden" name="docid">
110
										<xsl:attribute name="value">
111
                       <xsl:value-of select="./relationdoc" />
112
                     </xsl:attribute>
113
									</input>
114
								</xsl:for-each>
115

  
116
								<a>
117
									<xsl:attribute name="href">javascript:submitform('read',document.<xsl:value-of select="translate(./docid, '()-.', '____')" />)</xsl:attribute>
118
									<xsl:text>&#187;&#160;</xsl:text>
119
									<xsl:value-of select="./param[@name='assessment/@assessmentTitle']" />
120
									<!-- <xsl:value-of select="./param[@name='assessment/@assessmentId']" />) -->
121
								</a>
122
								(<xsl:value-of select="./docid" />)
123
							</form>
181
							<a>
182
								<xsl:attribute name="href">javascript:submitform('read','<xsl:value-of select="./docid" />',document.assessmentForm)</xsl:attribute>
183
								<xsl:text>&#187;&#160;</xsl:text>
184
								<xsl:value-of select="./param[@name='assessment/@assessmentTitle']" />
185
								<!-- <xsl:value-of select="./param[@name='assessment/@assessmentId']" />) -->
186
							</a>
187
							(<xsl:value-of select="./docid" />)
188
							<br />
189
							Response Data...
190
							<input type="checkbox" name="docids">
191
								<xsl:attribute name="value">
192
									<xsl:value-of select="./docid" />
193
								</xsl:attribute>
194
							</input>
195
							<br/>
196
							<a>
197
								<xsl:attribute name="href">javascript:getResponseData('<xsl:value-of select="./docid" />', '<xsl:value-of select="$divId" />')</xsl:attribute>
198
								<xsl:text>View</xsl:text>
199
							</a>
200
							/
201
							<a>
202
								<xsl:attribute name="href">javascript:hideDiv('<xsl:value-of select="$divId" />')</xsl:attribute>
203
								<xsl:text>Hide</xsl:text>
204
							</a>
205
							<!-- 
206
							/
207
							<a>
208
								<xsl:attribute name="href">javascript:getMergedResponseData('assessmentForm','mergedResponseData')</xsl:attribute>
209
								<xsl:text>Merge Selected</xsl:text>
210
							</a>
211
							 -->
212
							<div>
213
								<xsl:attribute name="id">
214
									<xsl:value-of select="$divId" />
215
								</xsl:attribute>
216
							</div>							
124 217
						</td>
125 218

  
126 219
						<td class="text_plain">
......
169 262
					</tr>
170 263

  
171 264
				</xsl:for-each>
265
				
172 266
			</table>
267
			
268
			</form>
269
			
173 270

  
174 271
		</xsl:if>
175 272
	</xsl:template>

Also available in: Unified diff