1 16 17 package org.apache.jetspeed.modules.layouts; 18 19 import org.apache.jetspeed.capability.CapabilityMap; 21 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService; 22 import org.apache.jetspeed.services.logging.JetspeedLogger; 23 import org.apache.jetspeed.services.rundata.JetspeedRunData; 24 import org.apache.jetspeed.services.resources.JetspeedResources; 25 import org.apache.jetspeed.util.MimeType; 26 27 import org.apache.turbine.modules.Layout; 29 import org.apache.turbine.modules.NavigationLoader; 30 import org.apache.turbine.modules.ScreenLoader; 31 import org.apache.turbine.util.RunData; 32 33 import org.apache.ecs.*; 35 import org.apache.ecs.wml.*; 36 import org.apache.ecs.xml.*; 37 38 47 public class JetspeedLayout extends Layout 48 { 49 50 public static final String TOP = 51 JetspeedResources.getString( JetspeedResources.NAVIGATIONS_TOP_KEY ); 52 53 public static final String BOTTOM = 54 JetspeedResources.getString( JetspeedResources.NAVIGATIONS_BOTTOM_KEY ); 55 56 59 public static final Doctype WML_DOCTYPE = 60 new Doctype( "wml", 61 "PUBLIC", 62 "\"-//WAPFORUM//DTD WML 1.1//EN\"", 63 "\"http://www.wapforum.org/DTD/wml_1.1.xml\"" ); 64 65 66 69 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(JetspeedLayout.class.getName()); 70 71 74 public void doBuild( RunData data ) throws Exception 75 { 76 77 CapabilityMap cm = ((JetspeedRunData)data).getCapability(); 78 79 MimeType mt = cm.getPreferredType(); 80 data.setContentType( mt.getContentType() ); 81 data.setCharSet( mt.getCharSet() ); 82 83 if ( logger.isDebugEnabled() ) 84 { 85 logger.debug( "Layout: Setting type to: " + mt ); 86 } 87 88 if ( mt.equals( MimeType.WML ) ) { 89 92 ElementContainer ec = new ElementContainer(); 93 WML wml = new WML(); 94 ec.addElement( new PI().setVersion( 1.0 ) ); 95 ec.addElement( WML_DOCTYPE ); 96 ec.addElement( wml ); 97 wml.addElement( new Template().addElement( new Do( DoType.ACCEPT, "Back" ).addElement( new Prev() ) ) ); 98 99 ConcreteElement screen = ScreenLoader.getInstance().eval ( data, data.getScreen() ); 101 if (screen != null) 102 wml.addElement( screen ); 103 104 try { 106 ec.output( data.getOut() ); 107 } catch ( java.io.IOException e ) { 108 logger.error("Exception", e); 109 } finally { 110 ec = null; 111 } 112 113 } else { 114 115 ConcreteElement topNav = 117 NavigationLoader.getInstance().eval ( data, TOP ); 118 if ( topNav != null) 119 data.getPage().getBody().addElement( topNav ); 120 121 ConcreteElement screen = ScreenLoader.getInstance().eval ( data, data.getScreen() ); 123 if (screen != null) 124 data.getPage().getBody().addElement( screen ); 125 126 data.getPage().getTitle() 129 .addElement( data.getTitle() ); 130 131 data.getPage().getBody() 134 .setBgColor(HtmlColor.white); 135 136 ConcreteElement bottomNav = 138 NavigationLoader.getInstance().eval ( data, BOTTOM ); 139 if ( bottomNav != null) 140 data.getPage().getBody().addElement( bottomNav ); 141 } 142 } 143 144 } 145 | Popular Tags |