How to check collection.contains(..) inside a tag ?

Hi,
I'm using both struts and jtsl tags in my jsp. JSP session has a Collection named "responses" that contains string objects.
    <c:forEach items="${page.questions}" var="question" varStatus="i">
          <tr>
               <th align="left"><c:out value="${question.questionId}. ${question.text}"></c:out></th>
          </tr>
        <c:forEach items="${question.answers}" var="answer" varStatus="j">
          <tr>
           <td>     
                     <c:set var="aKey" value="${question.OID}_${answer.OID}"></c:set>
                  <c:if test="${question.type == 1}">
                     <c:out value="${answer.answerId}"/>
                     <input id="<c:out value="KEY_${question.OID}"/>" name="<c:out value="KEY_${question.OID}"/>" type="radio" <c:if test="??? session.getAttribute("responses").contains(${question.OID}_${answer.OID}) ???" ><c:out value="selected=true"/></c:if> value="<c:out value="${question.OID}_${answer.OID}"/>"><c:out value="${answer.text}"/>                 
                  </c:if>
                  <c:if test="${question.type == 2}">
                     <c:out value="${answer.answerId}"/>
                     <input id="<c:out value="KEY_${answer.OID}"/>" name="<c:out value="KEY_${answer.OID}"/>" type="checkbox"  value="<c:out value="${question.OID}_${answer.OID}"/>"><c:out value="${answer.text}"/>                 
                  </c:if>                  
             </td>
        </tr>                  
        </c:forEach>
     </c:forEach>Please see the following line in the code
<c:if test="??? session.getAttribute("responses").contains(${question.OID}_${answer.OID}) ???" ><c:out value="selected=true"/></c:if>I need to check if a collection contains a string value or not. If contains I'm selecting the radio button otherwise not.
Any help will be appreciated!
Thanks

There is no way to tell if a collection contains a value.
If you changed your datastructure to a Map, you can check for the existence of a key in a map, but thats about it.
Alternatively write a static function for this operation, and import it into the jsp as an EL function.
Cheers,
evnafets

Similar Messages

  • How can i use JSTL inside custom tag attribute

    Hi,
    I have one button tag which displays the button with round corner. I will show the button like this:
    <ep:button key="buttons.submit" name="submitBtn" styleClass="But"
              onClick='submitPage(''<c:out value='${buttonName}' />)' />
    I am getting the problem with the above code. how can i use JSTL inside the custom tags.
    Thanks in Advance,
    LALITH

    No. The details are given below:
    I have included the follwing line in web.xml file:
    <taglib>
        <taglib-uri>/tags/button</taglib-uri>
        <taglib-location>/WEB-INF/button.tld</taglib-location>
      </taglib>button.tld file
    <taglib>
         <tlibversion>1.0</tlibversion>
         <jspversion>2.0</jspversion>
         <shortname>button</shortname>
         <tag>
              <name>button</name>
              <tagclass>com.ksi.ep.web.taglib.ButtonTag</tagclass>
              <bodycontent>empty</bodycontent>
              <attribute>
                   <name>name</name>
                   <required>true</required>
                   <rtexprvalue>false</rtexprvalue>
              </attribute>
              <attribute>
                   <name>key</name>
                   <required>true</required>
                   <rtexprvalue>true</rtexprvalue>
              </attribute>
              <attribute>
                   <name>onClick</name>
                   <required>true</required>
                   <rtexprvalue>true</rtexprvalue>
              </attribute>
    </taglib>ButtonTag.java :
    public class ButtonTag extends TagSupport {
       private static final long serialVersionUID = 6837146537426981407L;
         * Initialise the logger for the class
        protected final transient Log log = LogFactory.getLog(ButtonTag.class);
         *  holds the Value of the button tag
        protected String onClick = null;
         *  holds message resources key
        protected String key = null;
         * The message resources for this package.
        protected static MessageResources messages =
                             MessageResources.getMessageResources
                                       ("ApplicationResources");
          *  (non-Javadoc)
          * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
         public int doStartTag() throws JspException {    
            StringBuffer label = new StringBuffer();         
            HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
            try {             
                   log.debug("in doStartTag()");
                   Locale locale = pageContext.getRequest().getLocale();
                 if (locale == null) {
                     locale = Locale.getDefault();
                 log.info("");
                 label.append("<a border=\"0\" style=\"text-decoration:none;color:#FFFFFF\" href=\"JavaScript:");
                 label.append(onClick);
                 label.append("\" >");
                   label.append("<table  onClick=\"");
                   label.append(onClick);               
                   label.append("\" ");
                   if(onmouseout!=null && !"".equalsIgnoreCase(onmouseout))
                    label.append(" onmouseout=\"");
                    label.append(onmouseout);               
                    label.append("\" ");
                   if(onmouseover!=null && !"".equalsIgnoreCase(onmouseover)){
                    label.append(" onmouseover=\"");
                    label.append(onmouseover);               
                    label.append("\" ");
                   if(title!=null && !"".equalsIgnoreCase(title)){
                    label.append(" title=\"");
                    label.append(title);               
                    label.append("\" ");
                   label.append("style=\"cursor:hand\" tabindex=\"1\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"");
                   label.append(request.getContextPath());
                   label.append(System.getProperty("file.separator"));
                   label.append("images");
                   label.append(System.getProperty("file.separator"));
                   label.append("background1.jpg\" > ");
                 label.append("<tr><td width=\"10\"><img  border=\"0\" src=\"");
                 label.append(request.getContextPath());
                   label.append(System.getProperty("file.separator"));
                   label.append("images");
                   label.append(System.getProperty("file.separator"));
                 label.append("leftcorner.jpg\" ></td> ");
                 label.append("<td valign=\"middle\"  style=\"padding-bottom:2px\"><font color=\"#FFFFFF\" style=\"");
                 label.append(styleClass);
                 label.append("\">");
                 label.append(messages.getMessage(key));
                 label.append("</font></td>");
                 label.append("<td width=\"10\" align=\"right\"><img src=\"");
                 label.append(request.getContextPath());
                   label.append(System.getProperty("file.separator"));
                   label.append("images");
                   label.append(System.getProperty("file.separator"));            
                 label.append("rightcorner.jpg\" border=\"0\"  ></td>");
                 label.append("</tr></table></a>");
                 pageContext.getOut().print(label.toString());
              } catch (Exception e) {               
                   log.error("Exception occured while rendering the button", e);
                   throw new JspException(e);
            return (SKIP_BODY);
         * Release all allocated resources.
        public void release() {       
            this.name=null;
            this.key=null;
            this.onClick=null;
    }In my JSP I have mentioned the taglib directive as
    <%@ taglib uri="/tags/button" prefix="ep"%>and
    <ep:button key="buttons.submit" name="submitBtn" styleClass="But"
         onClick='overwritePreApprovals('<c:out value='${transactionalDetails['inPrepList']}' />')' />Servlet.service() for servlet action threw exception
    org.apache.jasper.JasperException: /pages/pms/coordinator/Dashboard.jsp(325,48) Unterminated <ep:button tag
    Thanks,
    LALITH

  • How does Smart Collection "contains words" work

    I have some pictures of ear rings which I have tagged with the keywords:
    ear rings, jewelry
    Note "ear rings" is 1 tag, it does not have a comma between them.
    I set up a smart collection with  "contains words" and typed "ear rings" (excluding quotes) in as the search criteria.  To my surprise LR3 found 0 matches!  I changed to "contains all" and then LR3 found the images.
    My question is why doesn't the "contains words" work?  It would seem that is the one I want to use over "contains all".

    What would happen if the keyword were instead ear-rings (or earings)?

  • How to check pdf contain hidden object?

    can any one help me to find the pdf contain hidden object or not.
    I try below code, its not working
    PDETextState objPDETextState;
    PDEText aotextObject;
    memset(&objPDETextState, 0,sizeof(PDETextState));
    aotextObject = (PDEText)aoPageElements;
    PDETextGetTextState(aotextObject,kPDETextRun,0,&objPDETextState,sizeof (PDETextState));
    if(objPDETextState.renderMode == kPDETextInvisible)
    AVAlertNote("Invisible");

    As per our discuss, I have attached screen shot and PDF.
    http://www.megafileupload.com/en/file/457275/ASV-BIF-20130828-014-pdf.html

  • How to insert a new line character inside CDATA tag in the source xml data file?

    values for form fields in the xml data file is contained inside CDATA tags which is an Unparsed Format.
    Eg: [CDATA[IBM-01 ~ DSHFSJDSJ ~ FGFGFJ, ~ VA 665665]] delimited by "~" char
    Actual o/p:-
    IBM-01 ~ DSHFSJDSJ ~ FGFGFJ, ~ VA 665665
    Expected o/p is like :-
    IBM-01
    DSHFSJDSJ
    FGFGFJ,
    VA 665665
    live cycle product does not interpret ~ as a newline character. Please suggest which character should be used instead inside CDATA section or if there is any other way to fix this?

    I do not have any problem while using IE's XML parser
    for XML+XSLT merging.That is because IE's parser does not implement XML correctly.
    But when I use JAXP's Transformer object, it does not
    preserve the new lines inside attribute values and
    converts those into white spaces.That is exactly what the XML specifications say should happen.
    >
    ----If you have text that contains newlines, you
    should put it in an element, not in
    ----an attribute.
    That would be my last solution. But I'd really hate
    to change my logic just 'coz JAXP is not capable of
    handling new lines inside attribute values. I may be
    wrong... but If IE can keep those then there has to
    be a way to do the same from server side merging....Sure. Write your own parser with the same bug in it. But you don't have any right to demand that other people supply you with parsers that work incorrectly.

  • How to check for the variable passed to a function inside a component

    I'm trying to pass a variable to a function inside of a
    component in a conditional statement.
    How to check the existance of this variable inside the
    function so that I can use the right <CFarguments>:
    in aForm.cfm I have:
    <cfinvoke component="#application.cfcroot#.business.Order"
    method="selOrderItems"
    returnvariable="q_OrderItems"
    OrderItemAbbreviation="Min"></cfinvoke>
    <cfset MCompIDs = ValueList(q_OrderItems.OrderItemID)>
    <cfif listFind(MCompIDs,attributes.CompID)>
    <cfset isM = true>
    <cfelse>
    <cfset isM = false>
    </cfif>
    <cfinvoke component="#application.cfcroot#.business.Order"
    method="selOrderItems"
    returnvariable="q_OrderItems"
    OrderItemAbbreviation="SMEnroll"></cfinvoke>
    <cfset SM_CompIDs =
    ValueList(q_OrderItems.OrderItemID)>
    <cfif listFind(SM_CompIDs,attributes.CompID)>
    <cfset isSM = true>
    <cfelse>
    <cfset isSM = false>
    </cfif>
    <CFIF isSM>
    <cfset temppath = frmcreator.buildFrm(isSMFlag=isSM)>
    <CFELSE>
    <cfset temppath = frmcreator.buildFrm(isMFlag=isM)>
    </CFIF>
    On aFormComp.cfc where the function is,
    I checked the existance of isSMFlag this way and I got error
    saying that :
    Context validation error for tag CFARGUMENT.; The tag must be
    nested inside a CFFUNCTION tag.
    How can I properly check the existance of isSMFlag inside the
    function so I can use the right cfarguments?
    <CFFUNCTION NAME="buildFrm" access="public"
    returntype="String" output="No">
    <cfif StructKeyExists(arguments, "isSMFlag")>
    <CFARGUMENT NAME="isSMFlag" REQUIRED="YES"
    TYPE="NUMERIC">
    <cfelse>
    <CFARGUMENT NAME="isMFlag" REQUIRED="YES"
    TYPE="NUMERIC">
    </cfif>
    ........ etc
    </CFFUNCTION>

    <CFFUNCTION NAME="buildFrm" access="public"
    returntype="String"
    output="No">
    <cfif StructKeyExists(arguments, "isSMFlag")>
    <CFARGUMENT NAME="isSMFlag" REQUIRED="YES"
    TYPE="NUMERIC">
    <cfelse>
    <CFARGUMENT NAME="isMFlag" REQUIRED="YES"
    TYPE="NUMERIC">
    </cfif>
    ........ etc
    </CFFUNCTION>
    NOT this way, that is for sure.
    The <cfargument ...> tag is for defining the arguments
    a function
    accepts either optional or not, but they are not required.
    Give this a
    try to see the differences.
    test.cfc
    <cfcomponent>
    <cffunction name="a">
    <cfdump var="#arguments#">
    </cffunction>
    <cffunction name="b">
    <cfargument name="foo">
    <cfargument name="bar">
    <cfdump var="#arguments#>
    </cffunction>
    </cfcomponent>
    test.cfm
    <cfset something = createObject("component","test")>
    <cfoutput>
    #something.a("blue","green")#
    #something.b("blue","green")#
    </cfoutput>
    Not tested or debugged so watch out for typos.

  • How to check postal code contains only 0 to 9

    Hi all,
    How to check postal code contains only 0 to 9
    thank you

    Hi
    Check the below link.It may help you out.
    http://help.sap.com/saphelp_47x200/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm
    Cheers,
    Hakim
    mark all useful answers

  • How to check for locks on a table inside a program?

    Hi Gurus,
    Kindly let me know how to check for a lock on a particular table inside a program.I know that we can see locks on table held by a user from transaction SM12 but my requirement is to check for lock on MARA/MARC/MARV if lock exist then bypass my code else do the code.
    Kindly suggest or give code to check for a lock on a particular table.
    Thanks in advance
    Sudipto

    FAQ.  Locked.

  • How to check whether a field contains at least one numeric value

    how to check whether a field contains at least one numeric value..

    Hi,
    I hope that this code will works.
    constants:
       c_digit_grp        TYPE char11         VALUE '0123456789',        " Digit group
    * Data Declaration
    data :
      str   type string.
    * if you want check entire string and pass entire string
    if  str CA c_digit_grp.
    * write your logic ---this block will execute atleast one numeric value exists in the string
    Endif.
    Regards
    Bhupal Reddy

  • How to import photos containing a tag from elements?

    how to import photos containing a tag from adobe elements 8?

    Tags are keywords.
    Other metadata:
    There is no way to share Faces from one system to another. Places will happen automatically if your photos have the gps co-ordinates in the Metadata. Events are populted depending on the choices you make in the iPhoto Preferences.
    Again, I'm not sure exactly what you're hoping for here, sorry.

  • How to add raw HTML tags inside JSF tags...

    Hi
    I would like to use <input type = text > inside my project in some area..The following code hides the input = type html tag and forwards the click event to jsf command button...After selecting the file,it should forward the value to jsf textfield....
    My code seems as below.
    <h:form id="detailForm" onsubmit="printElements(detailForm,this)">
    <f:verbatim>
    <input id="uploadFile" type="file" style ="dispaly:none"size="100" />
    </f:verbatim>
    <h:inputText id="docName" style="width:650px;" maxlength="100"/>
    <h:commandButton id="visibleBrowseButton" value="Select File..." onclick="'detailForm:uploadFile'.click();callClick();">
    </h:commandButton>
    </h:form>
    <script type="text/Javascript">
    function callClick()
    var val = document.detailForm.uploadFile.value;
    document.getElementById('detailForm:docName').value = val;
    </script>
    While running this page it works fine in IE but in Mozilla firefox it troubles me during detailForm:uploadFile'.click().
    I suspect the jsf page cannot able to detect the raw html tag inside jsf tags...Eventhough i tried using inside<f:verbatim> it wont works..
    I would like to know
    1.Whether the code is right,,if the code goes wrong why it got runned in IE not in firefox....
    2.How can raw html tags can be integrated inside JSF tags....

    First of all, why are you ignoring valuable answers about a JSF fileupload component in your previous topic?
    Second, you can just nest raw HTML anywhere in your JSF page. Your problem is rather related to JavaScript. It has completely nothing to do with Java nor JSF. Learn JavaScript -there is a nice tut at w3schools.com- and look for a JavaScript forum if you still stucks. There are ones at webdeveloper.com and dynamicdrive.com.
    The f:verbatim is only required if you was using JSF 1.1 or older, which is not the case. You would have occurred completely different problems.

  • How to check number of rows processed in a package

    i have a pakage wid at least 11 procedures which runs on running a report now user run the report and he told me that records are not fully processed records are less so how to check how many records are processed so i can conform the data
    its urgent plzz any suggestion
    thanks a lot

    And here's some hints for you posting on the forum...
    a) do not post in UPPER CASE unless you are highlighting a word or two. Typing everything in UPPER CASE, is considered shouting and is not polite.
    b) do not say that your requirement is "urgent". Everyone here is a volunteer with their own jobs to do and your requirement is not "urgent" to them. Suggesting they drop everything to help you is poor netiquete and, again, quite rude. It also presumes that your issue is somehow more important than other people who have posted asking for assistance. Sure, everyone else would like their question answering as soon as possible, but they aren't so rude as to demand urgent attention, so neither should you.
    c) Always tell us your database version. The answers you are given may vary depending on the capabilities of the database version you are using and if you don't specify a version, people will have to assume you are using the latest supported versions and the answers may not work for you if you have a less capable version, even if those answers are technically correct.
    d) Always try and give an example of what you mean. Provide sample tables (create table statements) and sample data (insert statements), with example code or queries that you've tried (where relevant), showing what you expect to get as output and explaining any logic that is to get from the source to the output.
    e) Post any code or data inside {noformat}{noformat} tags so that it retains formatting on the forum.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to check a XMLTYPE table for corrupted (not invalid!) XML records ??

    Hello,
    I'd like to get help on the following issue, please. I need to check the XML data in a number of tables with XMLTYPE data type. Some of the data is corrupted but in terms not that the XML format is wrong but there is no XML at all in the fields but just only, for example, control characters (no tags, no anything, just corrupted data).
    So, I have made a PL/SQL procedure cursor to get all the tables from a list, and then another cursor inside to browse each table for corrupted records. But can you help me how to check this? Any of the XML functions like for example: XMLIsValid, isFragment(), getrootelement(), etc. return to me an Oracle error "ORA-31011 XML parsing failed" and the procedure gets stuck on the first found bad record. But I need to continue and check all of them. Is it possible to get the ORA-31011 error with EXCEPTION, write to a logging table the corrupted record ID, and then continue?
    Here is my simple procedure:
    CREATE OR REPLACE PROCEDURE CHECKXML (v_schema in VARCHAR2)
    IS
         v_Message     VARCHAR2(254);
         sql_stmt1     VARCHAR2(1000);
         sql_stmt2     VARCHAR2(1000);
         c1           SYS_REFCURSOR;
         c2           SYS_REFCURSOR;
         cur_tab          varchar2(100);
         cur_appl     varchar2(100);
         cur_rec     varchar2(200);
         valid_flag     number;
         criteria     VARCHAR2(20);
         tab1          VARCHAR2(20);
         tab2          VARCHAR2(20);
    BEGIN
         criteria := 'XMLTYPE';
         sql_stmt1 := 'select id, path from ' || v_schema || '.stubfiles where type=:bcriteria';
         open c1 for sql_stmt1 using criteria;
         loop
         begin
              fetch c1 into cur_tab, cur_appl;
              exit when c1%notfound;
                   insert into system.log_table values (sysdate, v_schema, 'next table', 'id ' || cur_tab, 'appl ' || cur_appl, '');
              sql_stmt2 := 'select t.recid, t.xmlrecord.isFragment() from ' || v_schema || '.' || cur_tab || ' t';
              open c2 for sql_stmt2;
              loop
              begin
              fetch c2 into cur_rec, valid_flag;
                   exit when c2%notfound;
                   insert into system.log_table values (sysdate, v_Schema, 'next record', 'id ' || cur_tab, 'recid ' || cur_rec, 'valid ' || valid_flag);
                   commit;
              EXCEPTION
                   WHEN OTHERS THEN v_Message := sqlerrm;
                   dbms_output.put_line('Error for ' || cur_tab);
                   dbms_output.put_line('-' || v_Message);
                   insert into system.log_table values (sysdate, cur_tab, 'id err' || c_Row.ID,'appl err' || c_Row.path, v_Message,'');
              end;
              end loop;
              close c2;
              commit;
         end;
         end loop;
         close c1;
         commit;
    END CHECKXML;
    Thanks in advance
    Evgeni

    Hi
    Why do you use a GTT? Just keep your xml in memory...
    HTH
    Chris

  • SAP Script - How to check a text element is empty in Script.

    Hello Friends,
                  I like to display a text element when it is not empty, otherwise I like to display some other text.
    I know how to read text element in Script, but 
    How to check a text element is empty in Script
    Thank you for your time.
    Senthil

    Hi Senthil,
    Inside text element, we print the variables.
    Variables actually gets printed in the form.
    if the variable contains value the variable gets printed on script. if not, then variable not gets printed.
    hope this helps.

  • How to check code for syntax errors

    How do I check or validate my html code in dreamweaver. I wish to see if all the braces and tags are closed or not
    please guide me

    Hi There:
    You can check to make sure the tags, parentheses (( )), braces ({ }), and square brackets ([ ]) in your page are balanced. Balanced means that every opening tag, parenthesis, brace, or bracket has a corresponding closing one, and vice versa.
    Check for balanced tags
    Open the document in Code view.
    Place the insertion point in the nested code you want to check.
    Select Edit > Select Parent Tag.
    The enclosing matching tags (and their contents) are selected in your code. If you keep selecting Edit > Select Parent Tag, and your tags are balanced, eventually Dreamweaver will select the outermost html and /html tags.
    Check for balanced parentheses, braces, or square brackets
    Open the document in Code view.
    Place the insertion point in the code you want to check.
    Select Edit > Balance Braces.
    All of the code between the enclosing parentheses, braces, or square brackets is selected. Choosing Edit > Balance Braces again selects all of the code inside the parentheses, braces, or square brackets that enclose the new selection.
    And also make sure to validate your HTML code at - http://validator.w3.org/
    Regards
    Vinay

Maybe you are looking for

  • ORA-00980: synonym translation is no longer valid

    Hi I get the following error when try to insert xml SQL> ed Wrote file afiedt.buf 1 insert into "bulkCmConfigDataFile_TAB" 2 values( 3 XDB_UTILITIES.getXMLFromFile('Test.xml','DATA_DIR'). 4 createSchemaBasedXML('http://127.0.0.1:8081/public/xsds/conf

  • Defaulting variable in select query

    Hi Experts,   I am having some different requirement here like, while selecting data from a table, for some column need to deafult some constant value for all lines if the actual value in the DB table has no value. There are some aggregate results li

  • SD Queries

    I need guidance related to below issues...request you to reply me at the earliest.. 1)Fields in Customer master recoreds are not populating properly while taking  printouts... what camn be wrong in configuration/printer settings....it is basis settin

  • My quicktime browser plug-in isn't working

    I've configured all the plug-in options about what files quicktime should handle in the browser, but everytime a quicktime object should load in the browser window (such as movies, mp3s, interactive menus, even pop-ups and banners) all I get is a tor

  • Color Laser Jet 2600n color fading

    I installed new HP cartridges, but all colors are printing weak - magenta won't print at all.  Removed all cartridges and gently shook - reinstalled with no success.  Any ideas???   Thanks