Accepting traditional %= ... % dynamic attribute values in tags

I am using Tomcat 5.5 (Servlet 2.4). This JSP code works:
<% String strFoo = "index.jsp"; %>
<jsp:include page="<%= strFoo %>"/>
... but this code that uses a custom tag I wrote doesn't work:
<% String strFoo = "index.jsp"; %>
<myutil:check url="<%= strFoo %>">
some content
</myutil:check>
I get an error:
An error occurred at line: nnn in the jsp file: /xxxxxx.jsp
Generated servlet error:
strFoo cannot be resolved
I have set the "url" attribute's rtexprvalue setting to "true" for the myutil:check tag in its .tld file.
Does anyone have an idea about what might be wrong? I would have thought that what works for a jsp:include attribute should work for any tag attribute value with runtime evaulation enabled.
Of course, I would rather be using EL expressions, but I have a large body of existing code that I need to get working with this servlet container quickly, and rewriting it all is not an option at the moment.
Thanks

Looks good to me. I can't think of any reason why it shouldn't work.
Can you please show the tld (or an example tld) defining this tag?
If you could have some 'dummy' code to duplicate the issue, it will be easier to help.
One thing you might try - take a look at the code generated by the conversion into servlet. It should be in the [TOMCAT]/work directory.
See if you can figure out from there why strFoo would not be in scope. Maybe you had it nested in another block?
Hope this helps,
evnafets

Similar Messages

  • Spec oversight? Using dynamic-attributes in XML tag files

    I have a couple of tagfiles that generate form elements with specific conventions for the 'name' and 'value' attribute. Basically, a data binding framework.
    Dynamic attributes are useful because you can delegate all the usual html attributes to the generated HTML form element: SELECT, INPUT, id, class etc.
    The usual way to do this is to concatenate all the "pass-through" attributes to a string, and append this string to the element generated:
    <input type="hidden" name="foo" ${dynattrs}/>I'm wondering how to do this in a tagfile in XML format (mytag.tagx), since the XML format forbids syntax like in the example above.
    jsp:attribute won't help much, if it's nested inside a c:forEach: it won't apply to the right element.

    Ran into the same problem with 'optional attributes'. (see post "JSP 2.0 Tag files outputting elements with conditional attributes" http://forum.java.sun.com/thread.jspa?forumID=45&threadID=681033)
    Found a solution that is not very elegant but does work and saves you the trouble of reverting to Java Tags. Consider the following tag-file that outputs an html input-tag with conditional attributes:
    <?xml version="1.0" encoding="utf-8"?>
    <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:directive.attribute name="value" required="false" type="java.lang.String"/>
         <jsp:directive.attribute name="disabled" required="false" type="java.lang.Boolean"/>
         <jsp:directive.attribute name="hint" required="false" type="java.lang.String"/>
         <jsp:directive.attribute name="cssClass" required="false" type="java.lang.String"/>
         <jsp:text><![CDATA[<input type="text" name="]]><c:out value="${name}"/><![CDATA["]]></jsp:text>
         <c:if test="${!empty id}"><![CDATA[ id="]]><c:out value="${id}"/><![CDATA["]]></c:if>
         <c:if test="${!empty cssClass}"><![CDATA[ class="]]><c:out value="${disabled?(cssClass + '-disabled'):cssClass}"/><![CDATA["]]></c:if>
         <c:if test="${disabled}"><![CDATA[ disabled="disabled"]]></c:if>
         <c:choose>
              <c:when test="${!empty value}"><![CDATA[ value="]]><c:out value="${value}"/><![CDATA["]]></c:when>
              <c:when test="${!empty hint}"><![CDATA[ value="]]><c:out value="${hint}"/><![CDATA[" onfocus="if(this.value==']]><c:out value="${hint}"/><![CDATA[')this.value='';"]]></c:when>
         </c:choose>
         <jsp:text><![CDATA[/>]]></jsp:text>
    </jsp:root>In answer to your question: Yes, it looks like an oversight. Using the jsp:attribute tag in a c:forEach doesn't work because the attribute is then applied to the forEach tag. You would have to put the attribute-tag inside a jsp:body tag (inside the forEach). Then it would apply not to the forEach tag but to the tag enclosing the forEach. However, this doesn't work either, or at least it doesn't work in Tomcat 5.5. Could be a bug though, JSP 2.0 is still very buggy (for instance, using a tagfile inside another tagfile from the same taglib doesn't seem to work either...)
    Anyway, if you ever find a good solution please let me know by posting to this topic!
    TIA

  • Dynamic attributes in custom tag

    Hi,
    I am new to JSP, and i want to build a custom tag. in this custom tag i have declared for example 5 attributes. i want to have a custom tag that when i set the attribute1 content to "true", only attribute2 and attribute3 would be accessible and if i set the attribute1 content to "false", only attribute4 and attribute5 would be accessible
    <%@taglib uri="/WEB-INF/MyTLD2.tld" prefix="myTag" %>
    <myTag:DB attribute1 ="true" attribute2="Table1" attribute3="ID,Name,Tel" />
    <myTag:DB attribute1 ="false" attribute4="Table1" attribute5=" UpdateTable" />

    Or you could go for a more general definition of what the attributes mean. Instead of having 5 attributes that the user only needs 3 of, you could do something like:
    <myTag:DB sourceType="string" table="Table1" data="ID,Name,Tel"/>
    <myTag:DB sourceType="table" table="Table1" data="UpdateTable"/>
    (use just three attributes, all required, but with different expected values for the second or third attribute based on what the first one is).
    Then have your tag do:
            if ("string".equals(sourceType)) runStringSourceQuery(table, data);
            if ("table".equals(sourceType)) runTableSourceQuery(table, data);Either way, good documentation is needed to make sure what is needed under what circumstances.

  • Dynamic Attribute Class in Tag Lib TEI?

    Hi All
    I have had pretty good luck implementing a few tag libs.. my only question is..
    Can you dynamically assign the class type of an attribute in the TEI of a Tag? Is there a way to get at the TEI of a tag at runtime?
    As an example of what i'm asking to do, i would like to be able to return the variable "item" in a proper type so as to not have to cast it from a java.lang.object in the jsp script. (see the below code)
    public class myTEI extends TagExtraInfo {
    public VariableInfo[] getVariableInfo(TagData data) {
    return new VariableInfo[] {
    new VariableInfo("index", "java.lang.Integer", true, VariableInfo.NESTED),
    new VariableInfo("item", "java.lang.Object", true, VariableInfo.NESTED)
    Thanks for the help,
    Rick

    I propose you to pass object type as your tag attribute:
    <your:tag ... type="your.type.YourType" />
    And TEI class looks like:
    new VariableInfo("item", data.getAttributeString("type"), true, VariableInfo.NESTED)

  • Create a dynamic attribute for each user

    Hi All,
    I request you all to let me know how to give an approach to the following requirement.
    REQUIREMENT: I have to create a dynamic attribute in UME for each user and the read the attribute on lead selection of a table having list of Users.
                             On lead selection, the dynamic attribute value should be either true or false. Based on this value the rest of the application specific operations wil be taken care.
                              If a particular User does not have the dynamic attribute associated to it, then we need to create the same.
    Looking forwarrd for your help.
    Regards
    Dipendra

    //@@begin javadoc:UMSavePropertiesByNode()
         /** Declared method. */
      //@@end
      public boolean UMSavePropertiesByNode( )
        //@@begin UMSavePropertiesByNode()
              try {
                   if (wdContext.currentUserDataElement().getVaIUserMaint().setAttribute("com.sap.security.core.usermanagement", this.getUMPropertyName(null) + ".TableColumns", this.getPropertiesByNode())) {
                        wdContext.currentUserDataElement().getVaIUserMaint().save();
                        wdContext.currentUserDataElement().getVaIUserMaint().commit();
                        msg.reportMessage(IMessageTableUtilsComponent.UMPROPERTY__SAVE__FIELDS__SUCCESS, null, false);
              } catch (UMException ex) {
                   wdContext.currentUserDataElement().getVaIUserMaint().rollback();
                   msg.reportMessage(IMessageTableUtilsComponent.UMPROPERTY__SAVE__FIELDS__ERROR, null, false);
                   return false;
              return true;
        //@@end
      //@@begin javadoc:UMLoadFieldsProperties()
         /** Declared method. */
      //@@end
      public petrobras.com.br.classes.FieldsTable UMLoadFieldsProperties( petrobras.com.br.classes.FieldsTable fields )
        //@@begin UMLoadFieldsProperties()
              String properties[] = wdContext.currentUserDataElement().getVaIUserMaint().getAttribute("com.sap.security.core.usermanagement", this.getUMPropertyName(null) + ".TableColumns");
              if (Compare.getLenght(properties) > 0) {
                   //msg.reportWarning("[UMLoadFieldsProperties]: properties.length = " + properties.length);
                   for (int i = 0; i < properties.length; i++) {
                        int attrPos = Integer.parseInt(properties<i>.substring(properties<i>.indexOf("(") + 1, properties<i>.indexOf(")")));
                        String attrName = (String) properties<i>.substring(properties<i>.indexOf(")") + 1, properties<i>.indexOf("="));
                        int attrValue = Integer.parseInt(properties<i>.substring(properties<i>.indexOf("=") + 1, properties<i>.indexOf(";")));
                        Field item = fields.getField(attrName);
                        if (item != null) {
                             item.setPosition(attrPos);
                             item.setVisibility(WDVisibility.valueOf(attrValue));
                             fields.removeFieldByName(attrName);
                             fields.addField(item);
              return fields;
        //@@end
    regards,
    Angelo

  • Setting an attribute value of a tag equal to a String variable in scope

    Hi,
    I don't think this is possible because I get an "expression not allowed" error when trying it. But long story short I'm trying dynamically set attribute values on a taglib. For example:
    <%
    String value="attributevalue";
    // set the attribute of the tag below equal to this variable value
    %>
    <tag:mytaglib name="<%=value%>"/>
    I looked at the generated jsp page and seems like the variable "value" is not in scope of the method that processes the tag. Does anyone have any ideas or can confirm that there is no way to do this. Thanks!

    You can do it.
    In your tag library (*.tld) file, have an entry as:
        <attribute>
            <name>name</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>This should do the trick.
    Let us know if it worked for you.
    Thanks and regards,
    Pazhanikanthan. P

  • Use jsp tag output as another tag's attribute value

    I don't know anyone has ever tried this, one tag's attribute value needs to be dynamically set using another tag's output. Something like
    <layout:grid cols="<layout:write name="element" property="value"/>'' space='false'>
    </layout:grid>
    I want the cols attribute of grid tag to be the output of <layout:write name="element" property="value"/>
    The way I wrote is of course not working.
    But I know PHP can do things similar to this, JSP should be able to achieve something like this too.
    If anyone knows how to do this or using any alternative way to do this, please let me know.
    Shane

    something like this...
              OuterTag qParent = null;
              try {
                        Tag myParent = getParent();
                        while (myParent != null ) {
                          // loop up through tags until you find the one you want
                             if (myParent instanceof OuterTag) {
                                  qParent = (OuterTag) myParent;
                                  data = qParent.getSomeData();
                             } else {
                                  myParent = myParent.getParent();
                   }

  • Fixed values of dynamic attributes are not displayed for bid response

    Hi
    I have created a bid with dynamic attributes and have weighted the options with fixed values. I publish the Rfx (bid) and all is ok. The problem is that the fixed values are not displaying when doing a bid response.
    We are using SRM 7.0
    Can anyone help?

    No. Not yet. I think it is a bug. You should create an OSS message to SAP and ask them to pay special attention to the following code block:
    Class: /SAPSRM/CL_CH_WD_DODM_DYNATTR
    Method: /SAPSRM/IF_CLL_MAPPER~REFRESH
    At the end of the method, look for code context:
    IF lv_object_type = c_qte.
    *Set the Fixed Values Table to Invisible
        lv_visible = abap_false.

  • Tag Files: dynamic attributes

    Hello,
    I'm not quite sure what the following quote means. It's from the JSP 2.0 spec.
    For dynamic-attributes attribute of Tag File:
    "Only dynamic attributes with no uri are to be present in the Map; all other dynamic attributes are ignored."

    Could someone help me here?

  • Custom tag attribute values..

              hi,
              I have created custom tags from my EJB using ejb2jsp tool. I tried the following,
              1 works and the other doesn't,
              a) This works.
              <mytag:foo param1="<%="test"%>" />
              b) this gives me a "ClassCastException" <% String value = "test"; %> <mytag:foo param1="<%=value%>"
              />
              ----++++++ java.lang.ClassCastException: java.lang.Object at javax.servlet.jsp.tagext.TagData.getAttributeString(TagData.java:165)
              at com.niteo.projects.intelXML.xbrl.ejb.jsp_tags._XBRLContentProvider_se tIdTagTEI.isValid(_XBRLContentProvider_setIdTagTEI.java:37)
              at weblogic.servlet.jsp.StandardTagLib.verifyAttributes(StandardTagLib.j ava:443)
              ----++++++
              I have tried all possible tricks, but this doesn't work. Is there something that
              I missed while creating the custom tag Or is it the way I am using the tag..?
              any help pls...
              thx in advance -jay
              

    It seems like you want to be able to clear the default attribute and set an empty attribute in you custom tag. One way around this would be to pass a blank character in. That would force the default to be cleared with the blank. You could take it a step further and trim the attribute value before storing it. Alternatively you could set an overriding attribute such as:
    <slasher:foo name="slasher" ignorewhatever="true" />
    protected String whatever = "some default Value";
    public void setWhatever(String whatever)
         this.whatever = whatever;
    public void setIgnorewhatever(String ignore)
         if(ignore.equals("true"))
              this.whatever = "";
    }Cliff

  • UIX table tag's attribute VALUE is missing in jdev 10g production

    In JDeveloper 10g preview, I handled my table's navigation manually and need to set the table's tag attribute VALUE in order to keep the record range.
    However, when i convert my project to JDeveloper 10g Production, eventhought the page is still working fine, but in the design windows will show that the uix page is in invalid state and I found that the attribute VALUE is no more supported.
    Could anyone please help me and let me know how do i set back my record range? Thanks!

    It turns out that you're running into a bug that will be fixed in the soon to be released version of JDev 10g. The good news is that it's a design time bug, so your pages will still work at runtime. You can even fix the bug yourself if you want. In JDEV_HOME\jlib there is uix2-schemas.zip. Inside of that is ui/table.xsd.
    Add the below attribute definition inside of the complex type for the table, and you should be all set.
    <attribute name="value" type="ui:unsignedIntExpressionType" default="1"/>
    Hope this helps,
    Ryan Pollock
    UIX Team

  • "Unterminated value for attribute '' in XML Tag ''.(SBL-UIF-00265)"

    Getting this message when I do Edit Web Layout for a view in Siebel tools 7.8.2 "Unterminated value for attribute '' in XML tag ''.(SBL-UIF-00265)"...Anyone have any idea why I am getting this message?

    Thanks Joseph,
    Actually I looked at the Refer ID 1280569.1 before also, some how I could not figured it out the exact location as I was searching for two "(double quotes).
    Today I tried again and finally I found out the culprit. In my case actually there was no two double quotes, instead the " (double quote) was missing.
    Thanks again.
    Edited by: user624054 on Oct 5, 2011 8:10 AM

  • Why there is a difference in a "class" attribute value of html tag when viewed in "Page Source" and using "Inspector", I am refering to new Microsoft site?

    While inspecting the new Microsoft site source, I observed that the "class" attribute value of the "html" tag when seen in Page Source the value given by Tools/Web Developer/Inspect tool. Value with the tool indicates class="en-in js no-flexbox canvas no-touch backgroundsize cssanimations csstransforms csstransforms3d csstransitions fontface video audio svg inlinesvg" while that is given in Page Source is class="en-us no-js"
    The question is why different values are shown?

    Inspector is showing you the source after it's been modified by Javascript and such.
    To see the same thing in the source viewer, press '''Ctrl+A''' to select everything on the page, then right-click the selection and choose '''View Selection Source'''.

  • Object would have more then one attribute with the tag :VALUE

    I'm creating a new component in Ultiboard - a 100 pin connector.  This connector (Hirose) has 4 rows of 25 pins. Alternate rows are staggered. I'm trying to name each pin with it's appropiate name: A1, A2, A3 ....A50. Then B1, B2, B3 .....B50.
    When I change the VALUE or NUMBER attribute, I get the DRC error  message:
    This action cannot be completed because the resulting Object would have more then one attribute with the tag :VALUE
    Please remove one of the attributes and try again.
    Okay, so I've tried deleting the tag and now I can't name the pin at all. 
    What am I missing?

    You should be in the footprint editor to edit the pin name.  Select tools>>Database>>Database Manager, highlight the component in your database and click on the Edit icon.  In the footprint editor, double click on the pad and a SMT or THT pin Properties dialog appears, select the Attributes tab and highlight the Number row, press the change button and you should be able to change the pin name.   
    Tien P.
    National Instruments

  • Is it possible to regroup data based on attribute value of a tag?

    is it possible to regroup data based on attribute value of a tag?

    Hi Rajeev,
    You can filter records during import if one of the Matching field is of type Lookup.
    In your case if you create City as flat lookup table in MDM & maintain lookup values in DM(Just as an example), then you can import only records where city is HYD.
    Map Name & City, Then in Match Records tab select both the fields (Combination)
    then right click on it & select Filter.. option.
    Now new pop up will open where you be able to see ur Lookup table values, from there select HYD and Add
    Now in default Import Action, set Create Action for None/None (All other will be skip)
    This way you will import only HYD records.
    But this is possible only on Lookup fields & not foe Text fields
    Hope this will help you
    Thanks & Regards,
    Mahi

Maybe you are looking for

  • I would like to combine my word files to a pdf and i get errors for pdfmaker

    i would like to combine my word files to a pdf and i get errors for pdfmaker

  • Oracle 10g migration to linux

    Hi, At present we are maintaining a J2EE application running on a UNIX Platform with the following environment configuration: o Web Server (Apache 2.0.52) o Application Server (WebLogic Server 9.0) o Database Server (Oracle 9i) The current requiremen

  • Custom screen in IW22

    Hi.. Our Requirement is when a particular user status is set a button should appear in notification screen and on pressing the button a pop-up screen should appear to enter the maintenance details.

  • Ask your question.how do i transfere songs of my iphone onto my pc ?

    i recently got my iphone back after not using it for over 6 mounths, and need to back up all my music onto my pc ive never backed up onto a pc before and im having trouble working it out!!! CAN ANYONE HELP ???

  • Need to show frm-40400 message

    Hi, I would like to show this FRM-40400 message for non database field update to another table . Message should display in the status bar as "Frm-40400 Transaction Complete. 1 record applied and saved" Please tell me how can i handle this issue. Than