Help creating a custom tag from a scriplet

I am trying to make a cusom tag to replace this peice of code:
<TABLE >
<% 
out.println("<TABLE >\n" +
                "<TR BGCOLOR=\"#FFDDAA\">\n" +
                "  <TH>ID Number\n" +
                "  <TH>Artist\n"
Iterator it = pricePassed.getpricePassed().iterator();
while( it.hasNext() ){
   MySite.VideoBean vids = (MySite.VideoBean) it.next();
   out.println( "<TR>\n" +
               "<TD><Center><B>" + vids.getRecId() + "</TD>" +
                "<TD><Center><B>" + vids.getArtist() + "</TD>"
</TD></TR>\n" );
%></TABLE>The following is no where near perfect i just want to post it so i can get opinions to see if i am going about it the right way:
import java.io.*;
import java.util.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class TableTag extends BodyTagSupport {
private List passedIn;
public void setItems(List workon) {
  passedIn = workon;
public int doAfterBody() throws JspException {
  BodyContent body = getBodyContent();
  String body1 = body.getString();
   body.clearBody();
  List list = body1.length() >0 ? text2List(body1) : passedIn;
  if (list == null) return SKIP_BODY;
  try {
    JspWriter out = body.getEnclosingWriter();
    out.println("<TABLE BORDER=1 ALIGN=\"CENTER\">\n" +
                "<TR BGCOLOR=\"#AADDFF\">\n" +
                "  <TH>Artist\n" +     
Iterator it = passedIn.setItems().iterator();
while( it.hasNext() ){
   MySite.videoBean vids = (MySite.videoBean) it.next();
   out.println( "<TR BGCOLOR=\"#FFAD00\">\n" +
                "<TD><Center><B>" + vids.getArtist() + "</TD>"
</TD></TR>\n" );
  } catch (IOException ex) {
    throw new JspTagException(ex.getMessage());
  } // try
  return SKIP_BODY;
}

If you go to the page where it lists all the forums and scroll way, way, down you will find there's a JSP forum. That is really where you should post this kind of question.

Similar Messages

  • How To create a custom tag in jsf

    I'm trying to create a custom tag in jsf.what should be the approach to create it.it would be better if somebody will explain me from the skretch.

    There's a decent tutorial here, Priyo:
    http://www.exadel.com/tutorial/jsf/HowToWriteYourOwnJSFComponents.pdf
    Hope it helps,
    Illu

  • How to create a custom tag for a custom converter

    In Jdeveloper 11g, I have a project where I have created a custom converter class that impements the javax.faces.convert.Converter class. I have registered the converter with an id in the faces-config.xml file of the project, and the converter works fine by using the <f:converter type="myconverter"> tag. However, the custom converter has a field which I would like to set from the tag itself. Hence, I would like to add an attribute to <f:converter> tag if possible or create a custom tag that has the attribute.
    I have done some reserach and I found that a custom tag can be implemented: I need to create a class which extends from the ConverterTag class or javax.faces.webapp.ConverterElTag class, which I did, but I also need to create ".tld" (tag library) file which defines the tag itself.
    The part about creating the ".tld" file and registring the new tag is what I'm not sure how to do.
    Does someone know how to do this?
    thank you

    Hi frank,
    that's a good document, and it explains how to make a custom converter. I already created the custom converter, it converts a number to any currency pattern. I know java already has a currency converter, but it doesn't support Rupee currency format, and I need that format.
    My converter works, but I would like to pass the pattern of the format through an attribute in a tag. Since f:converter doesn't seem to support that, I created a custom tag which uses my converter, and it enables me to pass a pattern to the converter.
    All of that works, but I need to be able to pass the pattern as an EL expression, and it's not evaluating the expression before passing it to the converter. It just passes the whole expression as a string. I'm thinking It may be something I'm doing wrong.
    this is the tag library definition file:
    <!DOCTYPE taglib
    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
    "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
    <tlib-version>1.2</tlib-version>
    <jsp-version>2.1</jsp-version>
    <short-name>custom</short-name>
    <uri>custom-currency-converter</uri>
    <description>
    custom currency custom tag library
    </description>
    <tag>
    <name>CurrencyConverter</name>
    <tag-class>
    converter.Tag.CurrencyConverterTag
    </tag-class>
    <body-content>JSP</body-content>
    <attribute>
    <name>pattern</name>
    <type>java.util.String</type>
    <required>true</required>
    <rtexprvalue>true</rtexprvalue>
    </attribute>
    </tag>
    </taglib>
    Edited by: Abraham Ciokler on Feb 4, 2011 11:20 AM

  • Urgent-how to access custom tag from jsp tag

    I have a problem accessing a custom tag from a jsp expression.
    Details: I have a custom tag that returns a string variable. I need to access that variable from jsp expression <%%>.
    Can any body help me?

    Tags don't "return" values as in the normal sense.
    They can only support TEI (Tag Extra Information) that just stuffs a declared variable into the page's state.
    For example, if the tag class had a public method called getValue(), you could do the following:
    <xmp:mytag id="foo"/>
    <%
    out.println("value is " + foo.getValue());
    %>

  • Problem in creating a custom tag

    Hi All,
    I'm new to jstl. I want to create a custom tag. I created a sample java class and sample tld file and I used this file at my page it give me an error. The java and tag file code is as follow
    package mytag;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    * This is a simple tag example to show how content is added to the
    * output stream when a tag is encountered in a JSP page.
    public class Hello extends TagSupport {
         private String name=null;
          * Getter/Setter for the attribute name as defined in the tld file
          * for this tag
    public void setName(String value){
        name = value;
         public String getName(){
              return(name);
    * doStartTag is called by the JSP container when the tag is encountered
        public int doStartTag() {
           try {
            JspWriter out = pageContext.getOut();
            out.println("<table border=\"1\">");
              if (name != null)
               out.println("<tr><td> Hello " + name + " </td></tr>");
            else
               out.println("<tr><td> Hello World </td></tr>");
           } catch (Exception ex) {
             throw new Error("All is not well in the world.");
           // Must return SKIP_BODY because we are not supporting a body for this
           // tag.
           return SKIP_BODY;
    * doEndTag is called by the JSP container when the tag is closed
         public int doEndTag(){
            return EVAL_PAGE;
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
    "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
    <taglib>
         <tlibversion>1.0</tlibversion>
         <jspversion>1.1</jspversion>
         <shortname>sample</shortname>
         <info>My sample tag</info>
      <tag>
        <name>hello</name>
        <tagclass>tag.Hello</tagclass>
        <bodycontent>empty</bodycontent>
        <info>
         This is a simple hello tag.
        </info>
      <attribute>
          <name>name</name>
          <required>true</required>
          <rtexprvalue>true</rtexprvalue>
      </attribute>
    </tag>
    </taglib>And I use this tld file in my jsp code I got below error
    * org.apache.jasper.JasperException: /mytag.jsp(9,15) Unable to load tag handler class "tag.Hello" for tag "sample:hello"
    Help me about this problem.
    Edited by: Get2win4world on Dec 15, 2009 1:12 AM

    Your class (according to what is posted) is in the package mytag.
    So in your tld: <tagclass>tag.Hello</tagclass>should be<tagclass>mytag.Hello</tagclass>cheers,
    evnafets

  • Trying to create a custom tag

    I want to create a custom tag that has a attribute that ask
    for a number. like below...
    <cf_makeattributes number="?">
    Now say I made that number something like 5
    <cf_makeattributesnumber=
    "5">
    I would like for the tag to take that number and make 5
    attributes called "Form" in a array from 1 to 5 like below...
    <cfset attributes.form = arraynew(1)>
    <cfloop index="i" from="1" to="#attributes.number#">
    #attributes.form
    </cfloop>
    Is it possible to make a tag that ask for a number like 5 and
    make 5 attributes and within the same tag assign values to those 5
    attributes. for example consider the above.
    <cf_makeattributes number="5" attribute1="hi"
    attribute2="hello" attribute3="howdy" attribute4="hey"
    attribute5="HOWE!">
    or say i want to make 2 attributes and assign 2 values to
    those attributes
    <cf_makeattributes number="2" attribute1="This tag asked
    for 2 numbers" attribute2="and therefore gave me the ability to
    make 2 attributes">
    I also have another question that kinda applies to the
    question above.
    How does the coldfusion server read the tags. for example
    look at below
    <cf_makeattributes number="2" attribute1="hello"
    attribute2="world">
    would the server read it like this...
    step 1
    <
    cf_makeattributes number="2" attribute1="hello"
    attribute2="world">
    step 2
    <cf_makeattributes
    number="2" attribute1="hello" attribute2="world">
    step 3
    makeattributes.CFM (it now goes to the template that holds
    the tags scripts)
    Or does it first read all thats bold below
    <cf_makeattributes
    number="2" attribute1="hello" attribute2="world">
    then goes to the makeattributes template. Is there away I
    can compile my script one step at a time like C# and C++ just to
    see the steps
    PLUS Do i have to put my custom tag into a specific folder or
    can I just put it in the same folder as the document thats calling
    the custom tag

    > I could either make a bunch of attributes that will grab
    all the
    > values or I could loop out a array of attributes. Thats
    my goal
    I was with you until that line. The term attributes is
    confusing in this context. I'm not sure if you're talking about
    attributes in a generic sense or the custom tag attribute
    scope.
    > Now here wat im thinking now. What if instead I put the
    forms in a list. something like this...
    > <cf_Formentry
    Forms="#Form.one#,#form.two#,#form.three#">
    Do you mean form
    fields?
    Let's try this from a different angle. Can you give a
    concrete example of the desired results using this form?
    <form>
    <input name="username1" value="Alice">
    <input name="username2" value="Bob">
    <input name="username3" value="Kyle">
    <input name="username4" value="Michelle">
    <input name="username5" value="Robert">
    </form>

  • Calling jsp custom tag from jsp expression

    hi there,
    I have a problem calling oracle(or any other) custom tag from inside a jsp expression.(i.e.)embeding <jbo:tagname...> into <%......%>.
    For example:
    I need to get the value of a jsp parameter, but the parameter name is dynamic (retrieved from a DataBase)
    So I though it would be something link that:
    <%=request.getParameter(<jbo:ShowValue datasource="ds" dataitem="ParamName" ></jbo:ShowValue>) %>
    where <jbo:ShowValue is an Oracle custom tab that retrieves the value of a certain dataItem(certain field).
    But it does not work.........
    if any body can tell me how to overcome, or work around it, I'll be so pleased.
    Regards,
    Remoun Anwar

    Hi,
    You get the custom tag output into a hidden variable (say 'key') and use the request.getParameter("key")
    Hope u got the answer...
    Regards
    ravi

  • To create a customer invoice from vendor invoice

    Hi i have a requirement to create customer invoices from vendor invoice. i would like to know if it is feasible??
    if it is possible is there any bapi or function module to transfer data from the vendor invoices to the customer invoice.
    regards
    prasannakumar

    hi,
    refer to this below link
    http://help.sap.com/saphelp_47x200/helpdata/en/5f/e411bb044411d2bf5d0000e8a7386f/frameset.htm
    -Reward If helpful
    -chaitanya

  • Unable to create a custom tag

    Hi All
    i am trying to make a custom tag in jsp2.0. I have made the java class which override the doTag method. I have created the tld file and put it in the directly WEB-INF FOLDER.I have written a jsp as well which uses this tag and the uri in the jsp mathces the uri in the tld file. Then it gives me the error message that unable to find the tld file.
    then i made entry in the web.xml as well but now it is giving me an error:
    JSPG0227E: Exception caught while translating /UseCustom.jsp: /UseCustom.jsp(19,1) --> JSPG0009E: Unable to load tag handler class com.hcl.taghandlers
    I am using jstl 1.1 and jsp2.0 and the IBM Rational editor.
    please help as soon as possible.
    thanks in advance!!!!!!!!

    There was a very minute syntax mistake in the web.xml.
    now it is working fine.
    By the thanks to all those who devoted some time to think over it.

  • How to create the customizing TAG coloum in So10  transaction

    Hi All,
      I need to create the Tag Coloum in in SO10 ( standard text) transaction .
    Basically i want to create the customised tag format and attach it to the format where we will see all the standard tag in so10.
      I need to create the TAG in which first line should be start from 0.00 and from the second line onwards it should be start from the 2.3 .
    Dhiraj.

    Dhiraj,
    What you will have to do is to create a separate STYLE in sMART FORMS transaction and assign that STYLE to the TEXT in S010. You can do that Format --> Change STYLE.
    The tag column contains format keys which define the output formatting of the text or initiate control commands. The format keys possible and their respective meanings are defined in styles or forms. If a style or form is assigned to a text module you can use the paragraph formats defined there to format your text. Format keys which can be defined by the user can consist of one or two characters.
    I have not tried this though.
    regards,
    Ravi
    Note : Please mark the helpful answers

  • Passing params to custom tag from jsp

    Hi all, I have a problem passing params back to my custom tag. The tag handler has a "getPageNumber()" method which returns a value. Initially the value is set and if a link is clicked it passes that param to the tag handler. I am trying to get this value from the tag handler to update the value on the link parameter.
    Something like this:
    // processed tag
    <a href="mypage.jsp?page=1">Next page</a>
    // clicking "Next Page"
    <a href="mypage.jsp?page=2">Next page</a>
    // jsp
    <taglib:tag param="<%=getPageNumber()%>"  />
    // in tag lib
    private pagenumber=1;
                pagenumber++;
    getPageNumber(){
    return pagenumber;
    setPageNumber(int pagenumber){
       this.pagenumber=pagenumber
    }I'm not sure if this is the best way to do this or if what I am trying to do is even possible.
    Any advice would be greatly appreciated.
    Thanks :)

    Hi all, I have a problem passing params back to my custom tag. The tag handler has a "getPageNumber()" method which returns a value. Initially the value is set and if a link is clicked it passes that param to the tag handler. I am trying to get this value from the tag handler to update the value on the link parameter.
    Something like this:
    // processed tag
    <a href="mypage.jsp?page=1">Next page</a>
    // clicking "Next Page"
    <a href="mypage.jsp?page=2">Next page</a>
    // jsp
    <taglib:tag param="<%=getPageNumber()%>"  />
    // in tag lib
    private pagenumber=1;
                pagenumber++;
    getPageNumber(){
    return pagenumber;
    setPageNumber(int pagenumber){
       this.pagenumber=pagenumber
    }I'm not sure if this is the best way to do this or if what I am trying to do is even possible.
    Any advice would be greatly appreciated.
    Thanks :)

  • Creating Archlinux custom CD from w/i WinXP

    Hi all,
    Sorry if this has already been answered in the forums, but could't find it.
    I need to d/l all the current Archlinux base stuff plus KDE + misc stuff... and create a custom install CD through WinXP, is that possible?
    Why is there not a Archlinux 0.7.2 ISO??? with all the new CD kernels, modules for boot ...etc.  Getting net access w/ the current ISO is hard especially when all you have is a WinXP box can't gensync or whatever.
    p.s. SuSE 9.3 works fine... w/ net access dual boot 'n all... but that not installed any more :-(
    Thanks In Advance for any help.

    https://wiki.archlinux.org/index.php/In … ting_Linux ? it is the first result on the wiki for ``exisiting''

  • How to create a custom dialogbox from menuitem

    Hi everyone,
    I'm new to java swings and i'm creating a Menu application with a menu.
    I'm trying to open a dialog box with the menuitem. I tried JOptionPane and i got it and now i'm trying to create a customized dialog with JPanel. I tried a lot ...but i can't see anything in the Dialogbox.
    plz help me out.....
    Thank you ... here is my code
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.io.*;
    public class Frame3 extends JPanel {
         static final String BOX_TITLE = "IP Selection Dialog";
              public static JFrame frame;
         public Frame3() {
              frame.addWindowListener(new WindowAdapter()
                   public void windowClosing(WindowEvent e) {
                        String s1 = "Quit";
                        String s2 = "Cancel";
    Object[] options = {s1, s2};
    int n = JOptionPane.showOptionDialog(frame,
    "Do you really want to quit?",
    "Quit Confirmation",
    JOptionPane.YES_NO_OPTION,
    JOptionPane.QUESTION_MESSAGE,
    null,
    options,
    s1);
    if (n == JOptionPane.YES_OPTION) {
    System.exit(0);
    } else {
    return;
              frame.getContentPane().setLayout(new BorderLayout());
    JMenuBar menubar4 = new JMenuBar();
    final JMenu menu3 = new JMenu("File");
              menu3.setMnemonic('F');
         final JMenuItem menuItem1 = new JMenuItem("New Scan");
    menuItem1.setMnemonic(KeyEvent.VK_N);
    menuItem1.setAccelerator(KeyStroke.getKeyStroke(
    KeyEvent.VK_N, ActionEvent.ALT_MASK));
    menu3.add(menuItem1);
    menubar4.add(menu3);
         menuItem1.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
                   JPanel choicePanel = createSimpleDialogBox();
    System.out.println("passed createSimpleDialogBox");
    JLabel title = new JLabel("Click the \"Vote\" button", JLabel.CENTER);
    JLabel label = new JLabel("OK", JLabel.CENTER);
    label.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
    choicePanel.setBorder(BorderFactory.createEmptyBorder(20,20,5,20));
    add(title, BorderLayout.NORTH);
    add(label, BorderLayout.SOUTH);
    add(choicePanel, BorderLayout.CENTER);
    String simpleDialogDesc = "Menus";
         public JPanel createSimpleDialogBox() {
    JButton vbutton = null;
    final String defaultMessageCommand;
    final String yesNoCommand;
    JRadioButton radio1 = new JRadioButton("Hello");
    radio1.setActionCommand(defaultMessageCommand);
    JRadioButton radio2 = new JRadioButton("How ru");
    radio2.setActionCommand(yesNoCommand);
    radio1.setSelected(true);
    vbutton = new JButton("OK");
    public final static void main(String[] args) {
              frame = new JFrame("abcd");
              Frame3 frame1 = new Frame3();
              frame.getContentPane().add("South", frame1);          
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              frame.pack();
              frame.setSize(1200,900);
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
    }

    Check out my StandardDialog class
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=678408
    you can fill in the content using setMainPane and synchronize on it by using the static showStandardDialog method
    I find it pretty useful

  • Need help creating a custom formula in a form

    I'm trying to create a custom formula for for our Order entry. I want to be able to put in the quantity, list price, and discount percent and have it calculate what the extended price will be? The formula I came up with was (ListPrice * Discount1/100)* Quantity1 but that didn't work.
    Here is what the spreadsheet looks like
    [IMG]http://i.imgur.com/JTV5QUW.png[/IMG]
    Does that make sense?

    Only if your discount percent field is formatted as "Number" and not as a 'Percentage".
    Images do not provide enough detail about the form, scripts, fields, field formats, etc to be much help.
    Are you getting any error messages in the JavaScript console?
    Change the format for the result field to "None" and observe the result.
    Your code is definitely not JavaScript that would work in an Acrobat form field.
    Are you using LiveCycle Designer to make your form?
    Are you using the "Simplified Field Notation" option?

  • Help - Creating a Custom Layout

    Hy, I'm creating a Grphical Programming Language,
    where user draw flowcharts by linking buttons.
    My problem is:
    After adding some buttons on the panel,
    the scrollBars does not appear.
    (I have set layout to be NULL so that I can add the buttons
    at specific position on the pane).
    I think I need to create a custom layout, but with a layout,
    after adding buttons on the panel and position them to specific
    location, when I maximize/restore the window, the buttons return
    to their initial position.
    Can anyone please send me the code for creating a custom layout (imagine
    that you are drawing a flowchart by adding buttons).
    NOTE: The buttons should stay at their position while maximizing/restoring
    the window.
    thanks in advance

    Hi,
    I'm currently working in a project that for what I understood is quite similar to yours...
    The way I solved the problem, was creating a virtual-grid. When the user adds the button, I have to methods (getRow() and getColumn())
    that convert the mouse coordinates to row and grid numbers. Then knowing the row and the column, I multiply this values for the row
    width and column height, and have the X and Y position where to add the button in the JPanel.
    Here is some of the code:
    public int getColumn(int x)//mouse coordinate x
            column=(int)(x/COL_WIDTH+1);
            if(maxColumn<column)
                maxColumn=column;
            return column;
        public int getRow(int y)//mouse coordinate y
            row=(int)(y/COL_HEIGHT+1);
            if(maxRow<row)
                maxRow=row;
            return row;
        }And then I add the component,
    jPanelContainer.add(component,
                        new org.netbeans.lib.awtextra.AbsoluteConstraints((col-1)*COL_WIDTH, (row-1)*COL_HEIGHT, -1, -1));This is only an ideia. Since I have a lot of constraints with the blocks that I have to add, I first add the components to an array[][],
    treat all the things in this array (like user deleted component, moves rows and columns, user added component, user moved component, etc...)
    and then "send it to the sreen"...
    Maybe I was a little bit confusing...
    Hope it helps!
    Regards,
    ANeto

Maybe you are looking for

  • Write to job log

    Hi,    I am running report in background have used job_open,job_close and submit statement.Actally in my scenario 2 report are running so 2 spool number is getting generate

  • Urgent !!Report Fiscal year for each Month i.e.12mnths

    Hi All,   I have a cube with following details. 1.Revenue Value ==1200 2.Fiscal year==2007 3.Product type==A But If i need to create a Dashboard Report with this Cube, But it has display tht Fiscal Year Value 2000 for each month Like ..KF=1200/12(mon

  • I don't want to discuss my problem, I need an answer.

    I need to know why Adobe reader won't work for me.

  • ABAP Development Video legal question

    Dear Community, We would like to create something like a video tutorial for ABAP development for the beginner level based on the flight data model. We might simply put it on our websites unrestriced area, membership area or we might sell this as a pr

  • Service entry sheet validation required

    Dear Experts, i am facing a problem while accepting service entry sheet, the scenario is as follow; when accepting service entry sheet reference to PO, the price change indicator is set in order to allow the users to enter a price not percentage, the