Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/obinary/cms/taglibs/util/StrToObj.java


1   /**
2    *
3    * Magnolia and its source-code is licensed under the LGPL.
4    * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5    * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6    * you are required to provide proper attribution to obinary.
7    * If you reproduce or distribute the document without making any substantive modifications to its content,
8    * please use the following attribution line:
9    *
10   * Copyright 1993-2003 obinary Ltd. (http://www.obinary.com) All rights reserved.
11   *
12   * */
13  
14  
15  
16  
17  
18  
19  package com.obinary.cms.taglibs.util;
20  
21  import javax.servlet.jsp.PageContext;
22  import javax.servlet.jsp.tagext.BodyTagSupport;
23  
24  
25  /**
26   * Date: Oct 7, 2003
27   * Time: 9:32:32 AM
28   * @author Vinzenz Wyser
29   * @version 1.0
30   */
31  
32  
33  public class StrToObj extends BodyTagSupport{
34  
35      public String var;
36      public String delims = "\n";
37  
38      public int doEndTag() {
39          //JspWriter out = pageContext.getOut();
40          String str = getBodyContent().getString();
41  
42          if (!str.equals("")) {
43              String[] obj = str.split(this.delims);
44              try {
45                  pageContext.setAttribute(this.var,obj,PageContext.PAGE_SCOPE);
46              }
47              catch (Exception e) {
48                  e.printStackTrace();
49              }
50          }
51          else {
52              try {
53                  pageContext.setAttribute(this.var,"",PageContext.PAGE_SCOPE);
54              }
55              catch (Exception e) {
56                  e.printStackTrace();
57              }
58          }
59          return EVAL_PAGE;
60      }
61  
62  
63      public void setVar(String var){
64          this.var = var;
65      }
66  
67      public void setDelims(String delims){
68          this.delims = delims;
69      }
70  
71  }