001 /** 002 * Copyright 2005-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package edu.sampleu.demo.kitchensink; 017 018 import javax.ws.rs.GET; 019 import javax.ws.rs.Path; 020 021 /** 022 * Test service exposed through REST and connected to a {@link org.kuali.rice.krad.uif.element.DataTable} 023 * component in the UIF 024 * 025 * @author Kuali Rice Team (rice.collab@kuali.org) 026 */ 027 @Path("/") 028 public class DataTableRestServiceTestImpl { 029 030 /** 031 * Returns a string of data in JSON format for populating the table 032 * 033 * @return String json data string 034 */ 035 @GET 036 @Path("/TableData") 037 public String getTableData() { 038 StringBuilder sb = new StringBuilder(); 039 040 sb.append("{ \"aaData\": [\n"); 041 042 for (int i = 0; i < 800; i++) { 043 sb.append("[\"CHEM " + i + "\","); 044 // add a hidden script to verify that it runs successfully 045 if (i % 10 == 0) { 046 String spanId = "nm_row_" + i; 047 sb.append("\"<span id='" + spanId + "'>INTRODUCTION TO GENERAL CHEMISTRY</span>"); 048 sb.append("<input type='hidden' name='script' value=\\\"jQuery('#" 049 + spanId + "').attr('style', 'color:green');\\\"/>\""); 050 sb.append(","); 051 } else { 052 sb.append("\"INTRODUCTION TO GENERAL CHEMISTRY\","); 053 } 054 sb.append("\"3\","); 055 sb.append("\"AU\","); 056 sb.append("\"NW\","); 057 sb.append("\"Neal\","); 058 sb.append("\"MWF\","); 059 sb.append("\"300.00\","); 060 sb.append("\"3\","); 061 sb.append("\"100\"]"); 062 063 if (i < 799) { 064 sb.append(",\n"); 065 } 066 } 067 068 sb.append("\n] }"); 069 070 return sb.toString(); 071 } 072 }