my defination File isn't execute

Help
Great
2004-11-02
2013-02-27
  • Great

    Great - 2004-11-02

    hello ..
    I am developing my web Application  through jsp and tld ... in tld class file i m writing small xkins code
    as describe in the Example but i m not  able to run it !
    i have written my definition ("/skins/TB/xskin1/definition.xml") is also their !
    While Compiling its not giving any err but the desire out put i am not getting

    import ar.com.koalas.xkins.XkinProcessor.*;
    import ar.com.koalas.xkins.*;
    import javax.servlet.jsp.tagext.Tag;
    import javax.servlet.jsp.tagext.IterationTag;
    import javax.servlet.jsp.tagext.BodyTag;
    import javax.servlet.jsp.tagext.TagSupport;
    import javax.servlet.jsp.tagext.BodyTagSupport;
    import javax.servlet.jsp.tagext.BodyContent;
    import javax.servlet.jsp.JspException;
    import javax.servlet.jsp.JspWriter;
    import javax.servlet.jsp.PageContext;
    import javax.servlet.ServletRequest;
    import java.io.PrintWriter;
    import java.io.IOException;

    public class HappyTag extends TagSupport {

        public HappyTag() {
            super();
        }

        public void otherDoStartTagOperations()  {

           
            try{
            System.out.println("1");
                JspWriter out = pageContext.getOut();

                Xkins xks = (new XkinsLoader()).loadSkins("/skins/TB/xskin1/definition.xml");
        
                Skin skin =  new Skin();
                skin.setUrl("/skins/TB/xskin1/definition.xml");

               // skin.setXkins((new Xkins()).addSkin("field"));

       //System.out.println(XkinProcessor.DEFAULT_SKIN + " hope not be null!");
       out.print("now going to call Xkins Enjeean");
              XkinProcessor xkp = new XkinProcessor();

              Template tmpBody = skin.getTemplate("field");
            
             // System.out.println(tmpBody.toString());
        
              xkp.setTemplate(tmpBody);
                       out.write(xkp.processContent());
                      xks.printHTML();

                 System.out.println(xkp.processContent());
                out.print("DO has Complited Sending Skin");
                System.out.println("DO complited succesfully");
            }catch(Exception e){
                e.printStackTrace();
                System.out.println(e.getMessage()+ "is errr!");
            }
        }

            public boolean theBodyShouldBeEvaluated()  {

                   return true;

        }

            public void otherDoEndTagOperations()  {

          

        }

            public boolean shouldEvaluateRestOfPageAfterEndTag()  {

                    return true;

        }

             public int doStartTag() throws JspException{
            otherDoStartTagOperations();

            if (theBodyShouldBeEvaluated()) {
                return EVAL_BODY_INCLUDE;
            } else {
                return SKIP_BODY;
            }
            public int doEndTag() throws JspException {
            otherDoEndTagOperations();

            if (shouldEvaluateRestOfPageAfterEndTag()) {
                return EVAL_PAGE;
            } else {
                return SKIP_PAGE;
            }
        }

    my deffnation.xml is

    <?xml version="1.0" encoding="UTF-8"?>
    <skin name="skin1" extends="base" default="true">

    <template name="field" >
      <content><![CDATA[

    "this line is coming from xskin"
       ]]></content>
    </template>
    </skin>

     
    • Guillermo Meyer

      Guillermo Meyer - 2004-11-02

      I think that you are using Xkins in the wrong way.
      Though you could use Xkins in some similar way as you are doing, in JSP/Taglibs arena it's intended to be used in the folloging way:

      1) Configure xkins in the web application:
          - Place the jar files in /WEB-INF/lib
         - Add in the /WEB-INF/web.xml the XkinsServlet declaration (see Xkins example)

      2) Add your skin:
          - create xkins-definition.xml file un /WEB-INF/classes with the following content:
      <?xml version="1.0" encoding="UTF-8"?>
      <xkins>
      <global-processor id="velocity" type="ar.com.koalas.xkins.processor.VelocityTemplateProcessor"/>
      <skin name="skin1" url="/skins/TB/xskin1"  definition="/definition.xml" defaultSkin="true"/>
      </xkins>

          - your skin (skin1) must have the definition.xml file with this content:
      <?xml version="1.0" encoding="UTF-8"?>
      <skin name="skin1">
      <processor id="velocity"/>
      <template name="field" >
      <content><![CDATA[
      this line is coming from xskin with a parameter: $param1
      ]]></content>
      </template>
      </skin>

      I remove the extends because in this example I'm not deploying the "basic" skin. If you take the basic skin from XkinsForms, you can add the extends attribute, but you have to declare this basic skin in the xkins.definition.xml file.

      3) Use the Xkins: In the taglib, the code should be something like this:

           public void otherDoStartTagOperations()  {
               try{
               System.out.println("1");
                   JspWriter out = pageContext.getOut();
                   //Creates the XklinProcessor
                   XkinProcessor xkp = new XkinProcessor("field", this.pageContext);

                   //add the parameters as desired
                   xkp.addParameter("param1", "value of the parameter");

                   out.print("now going to call Xkins Enjeean");

                   //uses processContent to process the template
                   out.write(xkp.processContent());
                   out.print("DO has Complited Sending Skin");
                   System.out.println("DO complited succesfully");
               }catch(Exception e){
                   e.printStackTrace();
                   System.out.println(e.getMessage()+ "is errr!");
               }
           }

      Hope this help.

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks