JSP 2.0 tag files for rendering JSF components

Over the weekend I read up on new JSP 2.0 features (dunno why I waited this long??) ... I really liked the tag file feature ...
I was wondering if it were a good idea to use these tag files as renderers for JSF components - ok, this ties us to a JSP only solution but how many in here would be using a non-JSP solution anyway?
I was thinking along the foll. lines:
<myComponent id="myComponent1" attr1="value1" attr2=value2">
    <myComponentRenderer var="myComponent1" />
</myComponent>
myComponentRenderer can be implemented as a tag file in myComponentRenderer.tag ... The myComponent tag delegates the business logic processing to its associated UIComponent and then sets this component as a pageContext attribute with the id "myComponent1" ... myComponentRenderer in turn gets a reference to this UIComponent and renders it ...
Again, if one wants a different way of rendering, make another tag file myComponentRenderer2.tag or change myComponentRenderer.tag itself ...
Indeed, this may not work for components with complicated rendering logic but I believe that's only the 20% case ...
Comments?
P.S.:
I've picked this up from http://forums.java.sun.com/thread.jsp?forum=427&thread=381052&tstart=0&trange=15
This also compliments another topic: http://forums.java.sun.com/thread.jsp?forum=427&thread=413515&tstart=0&trange=15

You are right in saying that decoding has nothing to
do with rendering per se.I will go even further than Erik did, and dispute this statement.
Consider that you are generating an <input> tag for a text field. Among other things, you have to generate a "name" attribute. Who decides what to put there? The renderer that actually created the markup.
The "renderer" really does
two completely different things. But both should
nevertheless be separate from the component
implementation itself. You could still have the
renderer doing the decoding part, which arguably would
rarely change, and somehow delegate the actual
rendering to an implementation in a tag file.Whether you implement decoding in a separate class or inside the component, what request parameter name do you look for? It is not reasonable to assume that ALL possible renderers will choose the same parameter name ... hence, decoding and encoding are inextricably linked (the code doing the decoding has to know what kind of markup the code doing the encoding actually created). In JavaServer Faces, the current APIs create that linkage by requiring that the decode and encode be done by the same class (either the component, if you are not delegating, or the renderer if you are).
Craig

Similar Messages

  • Tag files for rendering JSF components

    Hi people!
         It is possible to render component JSF using Tag-Files? (WEB-INF/tags).
    I am having problems with context, seems that the JSF does not recognize pageContext.
    Ex:
    My Tag-File
    <%@ attribute name="nameproperty" required="true" rtexprvalue="true" %>
    <%@ attribute name="size"           required="true" rtexprvalue="true" %>
    <h:inputText id="${nameproperty}"      size="#{size}" />
    My JSP
    <%@ taglib tagdir="/WEB-INF/tags" prefix="mayTags"%>
    <f:subview id="id001" >
         <myTags:myText propriedade="name_test" size="30" />
    </f:subview>
    In this in case that the size always is empty, because it does not recognize the target pageContext, but if I to place the size in the target of request already recognizes.
    EX:
    <%@ attribute name="nameproperty"      required="true" rtexprvalue="true" %>
    <%@ attribute name="size"           required="true" rtexprvalue="true" %>
    <c:set var"size" value="${size}" scope="request" >
    <h:inputText id="${nameproperty}"      size="#{size}" />
    In part it decides my problem, but it causes another error, is that if in my JSP it will have two fields (this is more than common) calling tag-file, there the size placed in request is always of it I finish field.
    Ex:
    <%@ taglib tagdir="/WEB-INF/tags" prefix="mayTags"%>
    <f:subview id="paisMan" >
         <myTags:myText propriedade="name_test" size="30" />
         <myTags:myText propriedade="name_test_2" size="70" />
    </f:subview>
    In this case all the two inputText would have size 70.
    It has some thing that I can make to solve this problem?
    Thanks for any help.
    Pedro Neves - Brazil

    You are right in saying that decoding has nothing to
    do with rendering per se.I will go even further than Erik did, and dispute this statement.
    Consider that you are generating an <input> tag for a text field. Among other things, you have to generate a "name" attribute. Who decides what to put there? The renderer that actually created the markup.
    The "renderer" really does
    two completely different things. But both should
    nevertheless be separate from the component
    implementation itself. You could still have the
    renderer doing the decoding part, which arguably would
    rarely change, and somehow delegate the actual
    rendering to an implementation in a tag file.Whether you implement decoding in a separate class or inside the component, what request parameter name do you look for? It is not reasonable to assume that ALL possible renderers will choose the same parameter name ... hence, decoding and encoding are inextricably linked (the code doing the decoding has to know what kind of markup the code doing the encoding actually created). In JavaServer Faces, the current APIs create that linkage by requiring that the decode and encode be done by the same class (either the component, if you are not delegating, or the renderer if you are).
    Craig

  • [weblogic-9.1] JSP 2.0 tag file gets compiled but not reloaded

    I am trying to use a JSP 2.0 tag file on weblogic 9.1. Everything works as expected until I reload the page after changing the tag file. Consider the following files, simple.jsp and simple.tag:
    h5. /simple.jsp
    &lt;%@ page language="java" %&gt;
    &lt;%@ taglib prefix="sandbox" tagdir="/WEB-INF/tags" %&gt;
    &lt;html&gt;
    &lt;body&gt;
    This output comes from the jsp.
    &lt;sandbox:simple&gt;
    &lt;/sandbox:simple&gt;
    &lt;/body&gt;
    &lt;/html&gt;h5. /WEB-INF/tags/simple.tag
    &lt;%@ tag language="java" %&gt;
    <div>This output comes from a tag file
    </div>The output of a call to simple.jsp is:
    <html><head>
    </head><body>
    This output comes from the JSP.
    <div>This output comes from a tag file</div>
    </body></html>So far, so good. Now I change the content of simple.tag to
    <%@ tag language="java" %>
    <div>This output comes from *simple.tag*<div>On a new call to simple.jsp,
    1. Weblogic notices that the file has been changed,
    2. generates the TagHandler .java file
    3. compiles the .java file
    But the new class file seems not to be loaded by weblogic; the resulting HTML does not change. It is not a browser cache issue, as I can see Javelin compilation errors. E.g., changing the tag file content to
    <%@ tag language="j" %>
    <div>This output comes from simple.tag</div>leads to the following (expected) error:
    Compilation of JSP File '/sandbox/simple.jsp' failed:
    simple.tag:1:18: "j" is not a valid setting for the language attribute.
    <%@ tag language="j" %>
    ^-^
    Changes to the .jsp file are reflected in the HTML output.
    Am I missing something? Is there any flag I have to set in my weblogic configuration?

    You are right in saying that decoding has nothing to
    do with rendering per se.I will go even further than Erik did, and dispute this statement.
    Consider that you are generating an <input> tag for a text field. Among other things, you have to generate a "name" attribute. Who decides what to put there? The renderer that actually created the markup.
    The "renderer" really does
    two completely different things. But both should
    nevertheless be separate from the component
    implementation itself. You could still have the
    renderer doing the decoding part, which arguably would
    rarely change, and somehow delegate the actual
    rendering to an implementation in a tag file.Whether you implement decoding in a separate class or inside the component, what request parameter name do you look for? It is not reasonable to assume that ALL possible renderers will choose the same parameter name ... hence, decoding and encoding are inextricably linked (the code doing the decoding has to know what kind of markup the code doing the encoding actually created). In JavaServer Faces, the current APIs create that linkage by requiring that the decode and encode be done by the same class (either the component, if you are not delegating, or the renderer if you are).
    Craig

  • JSP 2.0 tag files in jDeveloper 10g

    Hi, I'd like to create a set of UI components using JSP 2.0 tag files and have them available through the jDeveloper component palette for use in the visual edittor. I'd like jDeveloper to render the tags at design time like it can with regular old tags.
    Can this be done, and if so, how? I poked around in jDeveloper and on the web site without figuring it out... If I missed something obvious or there's docs online please point me in the right direction!
    Thanks,
    L.

    OK, so the integrated run-time supports JSP 2.0 and tag files. But what I'm after is support in the design-time components. Specifically, I want to produce a set of user interface components that I can place in the component palette and have rendered in the JSP visual editor.
    As far as I can tell (see previous post), jDeveloper's editor doesn't understand JSP 2.0 features. Therefore I suspect that the design-time as a whole doesn't and so I'll have to use regular Java tags for anything that needs to be able to be rendered at design time.
    Oh well. Maybe I can write a Java tag implementation that somehow invokes a tag file and just write a simple wrapper taglib specifically for use within jDeveloper at design time.
    L.

  • Prob in  working with jsp 2.0 tags fil

    hi all
    i am facing a prob working with jsp 2.0 tags files and hope to receive a possitive responce from your good self:-
    <p>
    how could i create a instance of a user defined class in a tags files .
    <p>eg.
    <tb:firsttag tableName="customer" className="createtable" packagename="package1">
    <BR>
    </tb:firsttag>
    what code i have to write in tag file to create a object of class createtable </br>
    thanks in advance, waiting for ur cooperation

    I'm not sure I understand your question, but...
    If you want to create a custom tag that will contain a body (data between the start and end tags) you will extend BodyTagSupport.
    HTH.

  • JSP 2.1 - tag files annotation

    Hi,
    In JSP 2.1 spec is specified that tag handlers that implement javax.servlet.jsp.tagext.SimpleTag could be annotated : JSP.7.1.11 Resource Injection. Tag files when compiled extend javax.servlet.jsp.tagext.SimpleTagSupport which class implements javax.servlet.jsp.tagext.SimpleTag.
    So my question is can my tag file be injected?
    <%@ tag import="javax.annotation.*" extends="javax.servlet.jsp.tagext.SimpleTagSupport" %>
    <%!      
         private String completeInjection = "injectionIsNotComplete!";
         @InjectionComplete
         private void echoInjection(){
              completeInjection = "injection Is Complete!";
    %>
    completeInjection:<%= completeInjection %>Thanks,
    Todor

    OK, so the integrated run-time supports JSP 2.0 and tag files. But what I'm after is support in the design-time components. Specifically, I want to produce a set of user interface components that I can place in the component palette and have rendered in the JSP visual editor.
    As far as I can tell (see previous post), jDeveloper's editor doesn't understand JSP 2.0 features. Therefore I suspect that the design-time as a whole doesn't and so I'll have to use regular Java tags for anything that needs to be able to be rendered at design time.
    Oh well. Maybe I can write a Java tag implementation that somehow invokes a tag file and just write a simple wrapper taglib specifically for use within jDeveloper at design time.
    L.

  • JSP 2.x - Tag files with body-content="JSP"

    I've been looking at the JSP 2.1 draft and see that, as with the previous JSP release, it is not allowed for tag-files to have body-content="JSP". I've tried to find a good answer for that on the web, but there's no one who can enlighten me. I've tried to tweak the source of Apache Tomcat 6.0.13 (Validator.ValidateVisitor and TagFileProcessor.TagFileDirectiveVisitor, both in org.apache.jasper.compiler) to accept body-content="JSP" in tag files - with great success. It is possible to have scriptlets within tags from tag files and it works as expected.
    My reason for wanting scriptlets in the body-content of tags from tag files is that it would encourage a more contextual, nested (and in my eyes, a more beautiful) structure of JSP-pages, as opposed to the JSTL flat structure, where f.ex. the sql:query tag does not reside within a sql:setDataSource tag, but instead refers to the datasource through an EL-variable. I suppose that it has been constructed in this way only to make it possible for programmers to include scriptlets in-between sql:query tags that use the same datasource.
    Not that it is not possible to nest tag-file tags, but I suspect that many programmers then would like to keep a flat structure so as to maintain the possibility of inserting scriptlets where needed - outside any tag which is based on a tag-file.
    So, why is it not allowed for tag-files to have body-content="JSP"?

    Thanks for the reply, evnafets.
    I'm aware that scriptet-code is generally being discouraged, although I don't understand why. I think that having a standard tag-library is a wonderful idea, but in the case of JSTL, I'm not that pleased. It relies heavily on EL, which I see as an unnecessary abstraction.
    Let me give you an example. The JSTL does database-connections and queries in this way:
    <sql:setDataSource var="datasource" url="jdbc:oracle:thin:@localhost:1521:TEMP" driver="oracle.jdbc.OracleDriver" user="scott" password="tiger" />
    <sql:query sql="SELECT * FROM EMP" dataSource="datasource" var="resultset" />This could also be accomplished without EL in a hierarchical structure:
    <sql:dataSource url="jdbc:oracle:thin:@localhost:1521:TEMP" driver="oracle.jdbc.OracleDriver" user="scott" password="tiger">
      <sql:query sql="SELECT * FROM EMP">
        BodyContent <% perhapsWithScriptlets; %>
      </sql:query>
    </sql:dataSource>...using TagSupport.findAncestorWithClass for the query to reference the datasource which it is enclosed in. (in Tomcat, the class would be called dataSource_tag. BTW, why is this not standardised in JSP?)
    I would then also like to be able to use scriptlet-code inside the tags as I could if the tags were written as tag-classes, extending BodyTagSupport, and being defined in a formal, cumbersome TLD file.
    Why the difference in functionality between SimpleTagSupport and BodyTagSupport - or rather; why is it then not possible to specify that a tag-file should extend BodyTagSupport rather than SimpleTagSupport?

  • JSP 2.0 tag file with conditional body?

    Is it possible to write a tag file that conditionally outputs its body?
    For example:
    <my:conditionalTag booleanAttr="false">
    Since booleanAttr is false, you will never see this output.
    </my:conditionalTag>
    Thanks,
    B

    I apologize for the typo..
    You can use the Java Standard Tag Library (JSTL), which has a <c:choose> tag with <c:when> or <c:if>. So as you can see with the example above, you are to use the <c:when> tag inside <c:choose> . Here is an example of using <c:if>(notice that you don't need the <c:choose> tag this time):
    <c:if test="${true}">
         do something
    </c:if>
    [/code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • JSP 2.0 Tag files outputting elements with conditional attributes

    It appears to be impossible to conditionally output element-attributes in JSP 2.0 XML Tag files. Here's an example:
    Tagfile text.tagx:
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
      <jsp:directive.attribute name="name" required="true" type="java.lang.String"/>
      <jsp:directive.attribute name="id" required="false" type="java.lang.String"/>
      <jsp:text>
        <input type="text" name="${name}" id="${id}" />
      </jsp:text>
    </jsp:root>Seems simple enough. This tag has a name-attribute and an optional id-attribute. But what if I want the id-attribute of the 'input' element not to be outputted when the id-parameter is empty!
    It appears there's no elegant way to do this but to revert to CDATA blocks and/or output-escaping. Is this an oversight in the API or am I missing something?
    I've also tried the following but it didn't work (in Tomcat anyway):
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2" xmlns:c="http://java.sun.com/jsp/jstl/core">
      <jsp:directive.attribute name="name" required="true" type="java.lang.String"/>
      <jsp:directive.attribute name="id" required="false" type="java.lang.String"/>
      <jsp:text>
        <jsp:element name="input">
          <jsp:attribute name="type" value="text"/>
          <jsp:attribute name="name" value="${name}"/>
          <c:if test="${!empty id}">
            <jsp:body>
              <jsp:attribute name="id" value="${id}"/>
            </jsp:body>
          </c:if>
        </jsp:element>
      </jsp:text>
    </jsp:root>Any ideas on how to do this?

    I wonder why no one has responded to this post!!!! I am trying to do the same thing, to no avial. In XSLT this is how it works, I would have thought JSTL would do the same thing. D'oh!

  • Keyword tag file for export

    Is there a keyword tag file I can export to use in Lightroom?
    Thanks, Doug Smith

    I tried that
    What did you try?
    PE only gives me the option of writing an .xml file
    I already explained there are several ways to go here, and so I can't understand why you feel the only option is writing an .xml file (which, by the way, is not one I am familiar with)
    It's like the fact that LR won't recognize my 6,000+ .png files,
    It's like the fact? Oh.
    Lightroom does not recognize .png files. They cannot be imported into Lightroom. You need to convert them to .jpg or .tif or .psd if you want them to be indexed in Lightroom. Which of course is a different issue than the one I thought we were addressing.

  • Tagging files for reflow under vista

    On my old computer (with windows 2000) I was able to move files from the laptop to my HP Ipaq 2790b and I could use the reflow feature on the Ipaq in Reader. When I moved to a new laptop and Vista I tried to get Adobe reader for pocket PC from the Adobe website and it said there were technical problems. I was afraid to try installing it with that warning. If I just drag a file from my laptop to the CF card in Microsoft Sync mode I can install the file on the Ipaq but the file is not tagged and as such I can't read it in reflow mode. I can still read the files in reflow that were installed last year on the Ipaq so I know it's not a problem with the Ipaq. Bill T.

    To Truly Julie:
    Thanks for your help. I was afraid that was the answer, but hoped I was just missing something. I've ordered a new laptop with XP and plan on putting the Vista machine in the closet for a while. Again thanks for the help.
    Bill T.

  • JSP Syntax for binding JSF components

    I am trying to bind to a map with session scope and the key into the map is
    a string value. It seems that this binding does not work as the key is not found
    before rendering.
    <f:selectItems id="listbox1SelectItems" value="#{idGeneratorBean.myIds['key']}"/>
    The key is a hidden field on the page, and if hard-coded in the above, it will find that data.
    I've seen other postings where the binding is done in the component's initialization code.
    If it is done that way, what should the jsp binding look like?

    Please don't crosspost topics over all places. Stick to one topic.
    Continue here: [http://forum.java.sun.com/thread.jspa?threadID=5299291]

  • Tags for bookmarks, what file in the Fox profile folder works with the tags? I'm sure it's not in places.sqlite -- I want to save the "tags" file for safekeeping.

    Tags for bookmarks ...

    The tags are stored in places.sqlite in the Tags folder and are also stored in a JSON backup.<br />
    So you can use a JSON backup to have a copy.
    *http://kb.mozillazine.org/Backing_up_and_restoring_bookmarks_-_Firefox

  • JSF Design Time View Not working correctly for ADF/JSF components

    My project is not using any external tag libraries. It is based purely on ADF core/html and JSF core/html components. The design time view does not show the appropriate presentation, everything is shown as nexted frame containers (I suppose how you would show a component that does not have a visual representation).
    If I create a new project and copy my jsp (jsf) pages over they show perfectly. I did this activity and all was going well in the new project and then I lost the design time view again. I cannot tell you what I did to cause the issue, maybe it was a modification to the web.xml as has been suggested in some other threads. Can anyone tell me what I should be looking for that causes this problem, what corrective actions I might take to eliminate the issues

    Ok I have isolated this issue. In my phase listener I had this line of code:
    private static final Logger _logger =  Logger.getLogger(EigRequest.class.getPackage().getName());
    and I changed it to
    private static final Logger _logger =
    Logger.getLogger(EigRequest.class.getName());
    and design mode started to work. I guess either of the above works for me although I do not understand why the line works when you run the application but not in design mode.
    Moral to the story is if something fails in any one of these types of decorators you will drop into a raw view mode. The question I have is if errors are occuring how do I figure out where they may be. There is no indication that anything is wrong with the exception that you lose most of the design mode functionality.
    This was not a compile issue, this was not a runtime issue. It took me quite a few hours of writing a test program to validate that it was not just writing a phase-listener issue; then launching, editing, relaunching the application to find the problem. I will say that a good portion of the code came from a Eclipse project. If you add the offending lines of code while using JDeveloper you do not loose design mode immediately. You only see the problem the next time you start JDeveloper which complicates finding the problem.

  • Where are configure files for Grid Control components?

    I installed Grid Control 11g on Redhat 5.2, the repository database is Oracle 11.2.0.2 on the same box. It worked after installation, but after some weeks, I restart oms and got error [oracle@cchbi bin]$ ./emctl start oms
    Oracle Enterprise Manager 11g Release 1 Grid Control
    Copyright (c) 1996, 2010 Oracle Corporation.  All rights reserved.
    Starting WebTier...
    WebTier Successfully Started
    Starting Oracle Management Server...
    Oracle Management Server is not functioning because of the following reason:
    Connection to the repository failed. Verify that the repository connection information provided is correct.Tried to google and search the forum, the message is not very selective and got few relevant resut.
    Hope your exterts can point me to the configure file where I can verify the connetion to repository. Alos some one would share with me the knowledge on the following topics
    1) What are the processes/components of Grid Control ? I am aware of oms, opmn, and a process run as /u01/app/midware/oms11g/ccr/bin/nmz -cron –silent. ANy others? What are their functions?
    2) Location of configure files, log files and binary executables of this processes/components.
    Many thnaks.

    Hi,
    to check if the OMS is running properly execute the command "emctl status oms" ($OMS_HOME/bin).
    The result should be "Oracle Management Server is up".
    To check which components are currently running execute the command "opmnctl status" ($OMS_HOME/opmn/bin).
    The result should be something like:
    Processes in Instance: EnterpriseManager0.<host
    -----------------------------------------------------------+---------
    ias-component | process-type | pid | status
    -----------------------------------------------------------+---------
    DSA | DSA | N/A | Down
    LogLoader | logloaderd | N/A | Down
    HTTP_Server | HTTP_Server | 26470 | Alive
    dcm-daemon | dcm-daemon | 26301 | Alive
    OC4J | home | 1953 | Alive
    OC4J | OC4J_EMPROV | 1954 | Alive
    OC4J | OC4J_EM | 26523 | Alive
    WebCache | WebCache | 27085 | Alive
    WebCache | WebCacheAdmin | 27086 | Alive
    Executing this command will answer your question whioch components need/should be up when using OEM/GC.
    You will find some logfiles of the OMS under $OMS_HOME/sysman/log (e.g. emoms.trc, emoms.log). Please check logfile OC4J~OC4J_EM~default_island~1 under $OMS_HOME/opmn/logs as well...
    To start the OMS you might try the command "opmnctl startall"...
    HTH

Maybe you are looking for

  • Execute Procedure

    Hi, I am having table like this: tmp_pdf ID NUMBER(9) PK pdf BLOB NULLABLE I wrote a procedure like insert_pdf. I am having SQL developer tool. I am using this statement to execute the procedure: EXECUTE insert_pdf(1,NULL); I am getting this error -

  • Conditions in Calculation Schema not reflecting in Purch Info Record

    Hi, We are using calculation procedure TAXIN. We have maintained Calculation Schema & maintained required conditions. When we checked for maintaining these conditions in Purchasing Info Record, (Transaction Code - ME11 / ME12), these conditions are n

  • Photo will not go to full screen

    iphoto will not open photos that i click on   I think the app has some bad or missing files gene

  • IMac intel - Can't get rid of the PPP icon on display!

    Hi there, someone please help me. I am new to apple computers, I have recently accidentally switched on a PPP connect. And it shows on the top of the screen in between AirPort and bluetooth, icon is a phone. I have deleted the PPP location, but its i

  • LabVIEW caught fatal signal - Segmentation fault

    Hi, I've just obtained the Linux version of LabVIEW 7.0 from my University for academic use on my home PC, and I am having some difficulty getting the program to run. I've installed all of the "labview70-*.rpm" files into "/opt" using the "bin/INSTAL