| 1 |
|
package be.dvw.administration.mvc.taglibs; |
| 2 |
|
|
| 3 |
|
import be.dvw.administration.mvc.navigation.LeftMenu; |
| 4 |
|
import be.dvw.administration.mvc.navigation.LeftMenuXSLTImpl; |
| 5 |
|
import org.apache.commons.logging.Log; |
| 6 |
|
import org.apache.commons.logging.LogFactory; |
| 7 |
|
import org.dom4j.DocumentException; |
| 8 |
|
import org.dom4j.io.OutputFormat; |
| 9 |
|
import org.dom4j.io.XMLWriter; |
| 10 |
|
|
| 11 |
|
import javax.servlet.jsp.JspException; |
| 12 |
|
import javax.servlet.jsp.tagext.BodyTagSupport; |
| 13 |
|
import javax.xml.transform.TransformerException; |
| 14 |
|
import java.io.IOException; |
| 15 |
|
import java.io.UnsupportedEncodingException; |
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
0 |
public class LeftMenuTag extends BodyTagSupport { |
| 25 |
|
|
| 26 |
|
|
| 27 |
0 |
private static Log LOG = LogFactory.getLog(LeftMenuTag.class); |
| 28 |
|
private String currentItem; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
public int doStartTag() throws JspException { |
| 36 |
|
|
| 37 |
0 |
LOG.debug("Executing the LeftMenuTag for currentItem " + currentItem); |
| 38 |
|
LeftMenu menu; |
| 39 |
|
try { |
| 40 |
0 |
menu = new LeftMenuXSLTImpl(currentItem); |
| 41 |
0 |
OutputFormat format = OutputFormat.createPrettyPrint(); |
| 42 |
|
XMLWriter writer; |
| 43 |
0 |
writer = new XMLWriter( pageContext.getOut() , format ); |
| 44 |
0 |
writer.write( menu.getCurrentMenu() ); |
| 45 |
0 |
} catch (DocumentException e) { |
| 46 |
0 |
e.printStackTrace(); |
| 47 |
0 |
} catch (TransformerException e) { |
| 48 |
0 |
e.printStackTrace(); |
| 49 |
0 |
} catch (UnsupportedEncodingException e) { |
| 50 |
0 |
e.printStackTrace(); |
| 51 |
0 |
} catch (IOException e) { |
| 52 |
0 |
e.printStackTrace(); |
| 53 |
0 |
} |
| 54 |
0 |
return SKIP_BODY; |
| 55 |
|
} |
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
public int doEndTag() throws JspException { |
| 63 |
0 |
return EVAL_PAGE; |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
public String getCurrentItem() { |
| 71 |
0 |
LOG.debug("Returning the currentItem " + currentItem); |
| 72 |
0 |
return currentItem; |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
public void setCurrentItem(String currentItem) { |
| 80 |
0 |
LOG.debug("Setting the currentItem to " + currentItem); |
| 81 |
0 |
this.currentItem = currentItem; |
| 82 |
0 |
} |
| 83 |
|
|
| 84 |
|
} |