Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 5 6 package simpleapp.presentation; 7 8 import java.util.Date ; 9 import org.enhydra.xml.xmlc.*; 11 import com.lutris.appserver.server.httpPresentation.*; 12 import org.w3c.dom.html.*; 13 import org.w3c.dom.*; 14 15 import simpleapp.spec.SimpleListOfDiscsFactory; 16 import simpleapp.spec.SimpleListOfDiscs; 17 18 19 public class SimplePresentation implements HttpPresentation { 20 21 27 28 29 30 31 32 public void run(HttpPresentationComms comms) 33 throws HttpPresentationException { 34 35 String [][] discList; 36 try { 37 SimpleListOfDiscs sdl = SimpleListOfDiscsFactory.createSimpleListOfDiscs("simpleapp.business.SimpleListOfDiscsImpl"); 38 discList = sdl.getDiscList(); 39 } catch (Exception ex){ 40 System.out.println("Exception: "+ex); 41 42 discList = new String [1][4]; 43 discList[0][0] = "SORRY, "; 44 discList[0][1] = "NO "; 45 discList[0][2] = "DISCS "; 46 discList[0][3] = "AVAILABLE!"; 47 48 } 49 50 String now = new Date ().toString(); 51 SimpleHTML simple =(SimpleHTML)comms.xmlcFactory.create(SimpleHTML.class); 53 54 simple.setTextTime(now); 55 56 HTMLTableRowElement templateRow = simple.getElementTemplateRow(); 57 HTMLElement artistCellTemplate = simple.getElementArtist(); 58 HTMLElement titleCellTemplate = simple.getElementTitle(); 59 HTMLElement genreCellTemplate = simple.getElementGenre(); 60 HTMLElement likeThisDisc = simple.getElementLikeThisDisc(); 61 62 templateRow.removeAttribute("id"); 63 artistCellTemplate.removeAttribute("id"); 64 titleCellTemplate.removeAttribute("id"); 65 genreCellTemplate.removeAttribute("id"); 66 likeThisDisc.removeAttribute("id"); 67 68 Node discTable = templateRow.getParentNode(); 69 70 for(int numDiscs = 0; numDiscs < discList.length; numDiscs++) { 71 simple.setTextArtist(discList[numDiscs][0]); 72 simple.setTextTitle(discList[numDiscs][1]); 73 simple.setTextGenre(discList[numDiscs][2]); 74 simple.setTextLikeThisDisc(discList[numDiscs][3]); 75 discTable.appendChild(templateRow.cloneNode(true)); 76 } 77 78 discTable.removeChild(templateRow); 79 80 comms.response.writeHTML(simple.toDocument()); 81 } 82 83 }
| Popular Tags
|