6 Replies Latest reply on Jun 3, 2013 12:37 AM by Henry Du

    own Seam component

    Rajesh kanna Newbie

      How to write my own Seam Components or how can i extend the functionality of a existing seam component ?

        • 1. Re: own Seam component
          Daniel Hinojosa Master

          Whew, I typed the following up for you. The whole thing took me an hour. It has everything you need to know about create Seam components.

          http://docs.jboss.com/seam/2.0.0.CR2/reference/en/html/index.html

          and as far as extending an existing seam component, just extend the component class with a component superclass and it all works fine. The superclass BTW of any component can be a component or just a class.

          Please come back if you have other questions. ;)

          • 2. Re: own Seam component
            Rajesh kanna Newbie

             

            "dhinojosa" wrote:
            Whew, I typed the following up for you. The whole thing took me an hour. It has everything you need to know about create Seam components.

            http://docs.jboss.com/seam/2.0.0.CR2/reference/en/html/index.html

            and as far as extending an existing seam component, just extend the component class with a component superclass and it all works fine. The superclass BTW of any component can be a component or just a class.

            Please come back if you have other questions. ;)

            That is not the one wht am looking, I am trying to create a seam UI component like <s:fileupload> and trying to add some more attributes to <s:fileUpload>
            How can i achive it? its more just like own jsp taglib or jsf taglibs..
            Thanks...

            • 3. Re: own Seam component
              Daniel Hinojosa Master

              OHHHH.....

              Download the source from cvs and take a look at the following files to see how to extend them...

              /src/main/org/jboss/seam/web/FileUploadException.java
              /ui/src/main/java/org/jboss/seam/ui/component/UIFileUpload.java
              /ui/src/main/java/org/jboss/seam/ui/renderkit/FileUploadRendererBase.java
              /ui/target/generated-component/java/org/jboss/seam/ui/component/html/HtmlFileUpload.java
              /ui/target/generated-component/java/org/jboss/seam/ui/taglib/FileUploadTag.java

              Depending on what you are doing, if you just want to change the look for the FileUpload just extend the FileUploadRenderer, if you want to add other functionality to the component itself you can extend UIFileUpload.

              In order to use your tag in facelets, you will need your own xml, and you can reference these file after building seam:
              ./ui/target/classes/META-INF/s.taglib.xml
              ./ui/target/generated-component/resources/META-INF/s.taglib.xml

              In order to use your tag with jsp, you will need your own tld and you can reference these files from seam:
              ./ui/target/classes/META-INF/s.tld
              ./ui/target/generated-component/resources/META-INF/s.tld

              • 4. Re: own Seam component
                Rajesh kanna Newbie

                 

                "dhinojosa" wrote:
                OHHHH.....

                Download the source from cvs and take a look at the following files to see how to extend them...

                /src/main/org/jboss/seam/web/FileUploadException.java
                /ui/src/main/java/org/jboss/seam/ui/component/UIFileUpload.java
                /ui/src/main/java/org/jboss/seam/ui/renderkit/FileUploadRendererBase.java
                /ui/target/generated-component/java/org/jboss/seam/ui/component/html/HtmlFileUpload.java
                /ui/target/generated-component/java/org/jboss/seam/ui/taglib/FileUploadTag.java

                Depending on what you are doing, if you just want to change the look for the FileUpload just extend the FileUploadRenderer, if you want to add other functionality to the component itself you can extend UIFileUpload.

                In order to use your tag in facelets, you will need your own xml, and you can reference these file after building seam:
                ./ui/target/classes/META-INF/s.taglib.xml
                ./ui/target/generated-component/resources/META-INF/s.taglib.xml

                In order to use your tag with jsp, you will need your own tld and you can reference these files from seam:
                ./ui/target/classes/META-INF/s.tld
                ./ui/target/generated-component/resources/META-INF/s.tld

                Thans 4 tht,
                exactly i did the same thing..wht am doing is am trying to add one new attribure <s:fileUpload> .the new attribute is going for tag just befire of <s:fileUpload>.
                can u suggest anything for this.Actully what am trying is to upload multiple files ..frm client,so i need to change the <s:fileUpload> functionality to my own logic ..any suggestions ..
                Thanks,

                • 5. Re: own Seam component
                  Rajesh kanna Newbie

                   

                  "rajesh2win" wrote:
                  "dhinojosa" wrote:
                  OHHHH.....

                  Download the source from cvs and take a look at the following files to see how to extend them...

                  /src/main/org/jboss/seam/web/FileUploadException.java
                  /ui/src/main/java/org/jboss/seam/ui/component/UIFileUpload.java
                  /ui/src/main/java/org/jboss/seam/ui/renderkit/FileUploadRendererBase.java
                  /ui/target/generated-component/java/org/jboss/seam/ui/component/html/HtmlFileUpload.java
                  /ui/target/generated-component/java/org/jboss/seam/ui/taglib/FileUploadTag.java

                  Depending on what you are doing, if you just want to change the look for the FileUpload just extend the FileUploadRenderer, if you want to add other functionality to the component itself you can extend UIFileUpload.

                  In order to use your tag in facelets, you will need your own xml, and you can reference these file after building seam:
                  ./ui/target/classes/META-INF/s.taglib.xml
                  ./ui/target/generated-component/resources/META-INF/s.taglib.xml

                  In order to use your tag with jsp, you will need your own tld and you can reference these files from seam:
                  ./ui/target/classes/META-INF/s.tld
                  ./ui/target/generated-component/resources/META-INF/s.tld

                  Thans 4 tht,
                  exactly i did the same thing..wht am doing is am trying to add one new attribure <s:fileUpload> .the new attribute is going for <span> tag just befire of <s:fileUpload>.
                  can u suggest anything for this.Actully what am trying is to upload multiple files ..frm client,so i need to change the <s:fileUpload> functionality to my own logic ..any suggestions ..
                  Thanks,

                  i.e new attribute is adding to span tag...

                  • 6. Re: own Seam component
                    Henry Du Newbie

                    Hi, maybe on one could answer my question due to long time no Re,

                    I wonder why I just do this but have this error. I use seam 2.2.2 final and want to create new tag like <s:fileUpload>,

                    error:

                    java.lang.ClassCastException: com.dmxtechnologies.visionta.ss.util.fileupload.UploadTag cannot be cast to javax.faces.component.UIComponent

                     

                    this my code:

                     

                    import org.jboss.seam.ui.taglib.FileUploadTag;

                     

                    public class UploadTag extends FileUploadTag {

                     

                     

                              @Override

                              public String getComponentType() {

                                        return "HtmlUpload";

                              }

                     

                     

                              @Override

                              public String getRendererType() {

                                        return "UploadRenderer";

                              }

                    }

                     

                    this my config in taglib.xml

                    <tag>

                            <tag-name>htmlUpload</tag-name>

                            <component>

                            <component-type>HtmlUpload</component-type>

                            </component>

                    </tag>

                     

                    this my config in faces-config.xml

                     

                    <component>

                            <component-type>HtmlUpload</component-type>

                            <component-class>com.dmxtechnologies.visionta.ss.util.fileupload.UploadTag</component-class>

                    </component>

                     

                     

                    have any errors?

                     

                    thanks,