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

Similar Messages

  • Error in committing data while using dynamic attributes

    Hi,
    Module: Performance Management
    Page: Give Final Ratings: Main Appraiser
    Here, I have used dynamic attributes to show the competency name without segments.
    I have added this attribute through controller and i passed value to this attribute in the same ProcessRequest method.
    But, when the manager tries to complete the appraisal for his employee by pressing the continue button in the above mentioned page, the following exception is throwing.
    "This competence already exists within the assessment."
    Is this dynamic attribute will be the problem for this?
    can any one please tell me?
    Thanks in advance,
    SAN

    Hi,
    If you added the column from Extended Controller. It should be a transient attribute to the VO and I think it should not create any issues.
    Error "This competence already exists within the assessment." looks like from an FND Message , You can try to debug this issue by finding the FND Message Name corresponding to the error and search the Message Name in the seeded code.
    -Idris

  • "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

  • How to use Euro symbol in xml tags?

    How to use Euro symbol in xml tags?

    What do you mean by "in xml tags"? Can you post a three-line XML snippet showing what you hope to achieve?

  • [JS] Find & Replace attribute in xml tags (InDesign CS4)

    Hi all,
    Can anyone help me please who i can find and change attribute in xml tags (InDesign CS4) files. I have both link tags but its other attribute different but one attribute same. So who i can change attribute preference.
    (1) one is
    (2) second is
    I want change link preference = 0 but only (2 number,  second) screen shoot. First screen shoot preference = 1 as it is.
    I want this but its manually
    Help me please. Thank you so much adv.
    Regard
    snegig

    Hi John Hawkinson,
    Thank you so much for replay. I am try Jeff, absqua code technique it is simply greet. But my problem is that my both tags link preference = 1 same and other link attribute almost same. So i am unable to change attribute.
    John my code below =>
    var doc = app.activeDocument,
    attNodes = doc.xmlElements[0].evaluateXPathExpression("//link[@preference = '1' or @role = 'generated']"), i, l;
    for (i = 0, l = attNodes.length; i < l; i++) {
    attNodes[i].xmlAttributes.item("preference").remove();
    John please update my code.
    Thank you so much adv.
    Regard
    snegig

  • DataWriter - removing attributes from xml tag at the start of document

    Hi,
    I'm using DataWriter for generating a large XML document, however I do not want the attributees of the starting xml tag to appear in the final file.
    Eg: <?xml version="1.0" {color:#ff0000}encoding="UTF-8" standalone="yes"{color}?>I do not want to output the part highlighted in red.
    What could be the possible ways to do it? I prefer if it can be removed in the begining itself instead of parsing the document and removing in the end.
    -TIA, saum
    Edited by: nkrust on Feb 15, 2010 4:29 PM

    try {
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        Marshaller marshaller = new Marshaller(new OutputStreamWriter(
                                  baos));
                        marshaller.marshal(ResponseContents);
                        // Create an object of type Document from the XML document
                        // created.
                        DocumentBuilderFactory domFactory = DocumentBuilderFactory
                                  .newInstance();
                        domFactory.setNamespaceAware(false);
                        DocumentBuilder builder = domFactory.newDocumentBuilder();
                        responseDoc = builder.parse(new ByteArrayInputStream(
                                  ResponseUtils.formatXMLString(baos.toString())));
                   } catch (IOException e) {
                        e.printStackTrace();
                        System.out.println(e.getMessage());
                   }

  • How to use cm_nodeName attribute of search tag in content queries ?

    hello,
    i want to know about cm_nodeName,cm_path attributes of search tag.Actually i want to directly reterieve concerned node,so that content should be directly reterieved from that node and it should not search into all the present nodes in repository,to improve performence.
    Problem is that above mentioned tags are not working.
    Peply as soon as possible

    You could always write your own authenticator (i do not know if you can configure BEA directly)

  • How to evaluate a bean property passed as attribute to a tag file?

    I wrote the following tag file:
    <%@ tag body-content="empty" %>
    <%@ attribute name="domain" required="true" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <select>
         <jsp:useBean id="codeManagerBean" class="blabla.CodeManagerBean" />
         <c:set var="domainMethod">codeManagerBean.${domain}</c:set>
         <c:forEach var="code" items="${domainMethod}">
              <option value="${code.symbol}">${code.description}</option>
         </c:forEach>
    </select> What I would like is to call a property of CodeManagerBean whose name was passed as an attribute.
    Let's say this tag is used with the attribute domain="currencyCodes", the combo box should be filled with values from CodeManagerBean#getCurrencyCodes().
    The problem is that, in order to define the value of items in the forEach instruction, I declared the variable domainMethod. Now I would like items to evaluate the method (and thus return an iterator in this case), and not a String (what it currently does...).
    Any idea?
    Colargol

    Hi,
    a managed property only gives you a anlde to a bean or property, it doesn't execute it. To execute a bean, you can use a custom JSF PhaseListener that calls a bean method. The reference to the bean is achieve through value binding
    ValueBinding vb = FacesContect.getCurrentInstance().getApplication().createValueBinding("Name of Managed Bean);
    TypeOfBean theBean =(TypeOfBean) vb.getValue(FacesContext.getCurrentInstance());
    .... theBean.theMethod() ...
    Frank

  • How to remove xmlns attribute from XML tag?

    Hello!
    I have a XMLType document:
    --- P R O B L E M # 1 ---
    <?xml version="1.0" encoding="windows-1257" ?>
    <RESPONSE xmlns="http://testserver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://testserver response.xsd">
    <DATA REQUEST_ID="111">
    <ENTITY name="PACKAGE_001">
    <ATTRIBUTE name="PERS_ID" value="1111" />
    <ATTRIBUTE name="FIRST_NAME" value="OLGA" />
    <ATTRIBUTE name="SURNAME" value="NOVIKOVA" />
    </ENTITY>
    </DATA>
    </RESPONSE>
    I very need to remove from RESPONSE tag all addition information. Result I need is:
    <?xml version="1.0" encoding="windows-1257" ?>
    <RESPONSE>
    <DATA REQUEST_ID="111">
    <ENTITY name="PACKAGE_001">
    <ATTRIBUTE name="PERS_ID" value="1111" />
    <ATTRIBUTE name="FIRST_NAME" value="OLGA" />
    <ATTRIBUTE name="SURNAME" value="NOVIKOVA" />
    </ENTITY>
    </DATA>
    </RESPONSE>
    What can I do in this situation? My Oracle version is 9.2.
    --- P R O B L E M # 2 ---
    How I can create from source XML this one:
    <?xml version="1.0" encoding="windows-1257" ?>
    <MY_RESPONSE>
    <RESPONSE xmlns="http://testserver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://testserver response.xsd">
    <DATA REQUEST_ID="111">
    <ENTITY name="PACKAGE_001">
    <ATTRIBUTE name="PERS_ID" value="1111" />
    <ATTRIBUTE name="FIRST_NAME" value="OLGA" />
    <ATTRIBUTE name="SURNAME" value="NOVIKOVA" />
    </ENTITY>
    </DATA>
    </RESPONSE>
    </MY_RESPONSE>
    Thanks for your answers!
    Flu

    Maybe the problem#1 can be solved with a simple pl/sql using REPLACE statement. start with the <RESPONSE and look for the end > and get the entire string and replace that with only <RESPONSE> or maybe you can achieve this using xmldom to delete the attributes as part of the element.
    PRoblem#2 can be solved in this way.
    select xmlelement("MY_RESPONSE",
    xmltype('<RESPONSE xmlns="http://testserver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://testserver response.xsd">
    <DATA REQUEST_ID="111">
    <ENTITY name="PACKAGE_001">
    <ATTRIBUTE name="PERS_ID" value="1111" />
    <ATTRIBUTE name="FIRST_NAME" value="OLGA" />
    <ATTRIBUTE name="SURNAME" value="NOVIKOVA" />
    </ENTITY>
    </DATA>
    </RESPONSE>')).GetClobVal()
    from dual
    /

  • 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.

  • 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

  • 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)

  • How to use Entity Attributes in excel Rule File

    Hello,
    I have defined two entities Entity A with two attributes and Entity B child of A with two attributes.
    I needed to have many instances of theses objects thats why i have chosen entities.
    I need to calculate for each entity a result depending on the values of the attributes filled by the user.
    My final goal is to have the sum of these calculated results.
    The issue i am facing is whenever i try to define a rule in Excel, OPM considers the attribute as global (and creates it) and not as entity level. I therefore have duplicate error.
    How can i tell Excel/OPM that the attribute is entity level ?
    Thank you.

    Make sure you are using exactly the same attribute text in Excel and in your properties file. You can also use the legend key to map from the attribute text to a shorter form.
    There isn't any magic here! If the text is the same it will match.
    If you provide the actual text of the attributes and entities you are using, we might notice something else.
    Davin.

  • 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?

  • How to use 'roles' attribute in action-mapping ?

    Hi,
    Can anybody tell me what are the steps needed to use 'roles' attribute in <action> tag of struts-config.xml file?
    I want to provide Action level security.
    Also pls post an example if u r having.
    Regards
    Veeru

    Hi,
    The RfcAdapter trys to find a Sender Agreement for this RFC call but the lookup failes. The values used for this lookup are:
    Sender Party/Sender Service: The values from Party and Service belonging to the sender channel.
    Sender Interface: The name of the RFC function module.
    Sender Namespace: The fix RFC namespace urn:sap-com:document:sap:rfc:functions
    Receiver Party/Receiver Service: These fields are empty. This will match the wildcard
    Regards,
    Suryanarayana

Maybe you are looking for