Using isDefined within a cfloop

I am trying to check a number of submitted form fields. The
forms fields are numbered Q11, Q12, Q13, Q14, etc. Rather than do a
set of steps for each form field, I'm trying to do it with cfloop.
I have it set up as:
<cfloop index="i" from="1" to="20">
<cfif isDefined('form.Q1i')>
Do this stuff
</cfif>
</cfloop>
I don't get any errors, but it also is not processing the 'Do
this stuff'. I've tried changing the format; ('form.Q1' & #i#,
and 'form.Q1' & i, and others. Then I get error messages.
Any clues to the problem?

>> This code Does Not [work]
That is because when using isDefined() the values *must*
reside within quotes inside the function. So,
isDefined("form.Q12#i#") is valid where isDefined('form.Q12' &
i) is not (the string "& i" is outside the required quotes).
Also, your reference to the unknown variable name is
incorrect. Since *i* is a dynamic variable that you are saving to
the name of another variable you'd need to reference it as
something like "form.Q12#i#" where *FORM.Q12" is the string and *i*
is the dynamic value.
So, using your code as a base to work from, try this:
<cfloop index="i" from="1" to="20">
<cfif isDefined("form.Q12#i#")><cfset Q12Temp =
Q12Temp & ", " & "form.Q12#i#" /></cfif>
</cfloop>
Or to be a little cleaner, try this:
<cfloop index="i" from="1" to="20">
<cfif structKeyExists(form, "Q12#i#")><cfset Q12Temp
= listAppend(Q12Temp, "form.Q12#i#") /></cfif>
</cfloop>

Similar Messages

  • Using IsDefined()

    I have a web app that deals with both authenticated users (who log in via a central login) and unauthenticated ones.
    For the authenticated ones, I call a web service that returns an XML file.  I'm using this code:
    <cfif IsDefined("session.loginauth")>
        <cfset session.logincreds = XMLParse(session.loginauth)>
            <cfset session.userid = session.logincreds.user.row[1].user_id.XmlText>
            <cfset session.rights = session.logincreds.user.row[1].user_type.XmlText>
            <cfset session.usernm =  session.logincreds.user.row[1].name_first.XmlText & " " & session.logincreds.user.row[1].name_last.XmlText>
    </cfif>
    It works fine for authenticated users, but fails for unauthenticated ones.  The error is on the line with the XMLParse().  It's like the IsDefined isn't working and the code within the cfif is firing no matter what.
    I've tried cfparam'ing that session variable like this:
    <cfparam name="session.loginauth" default="">
    Then:
    <cfif session.loginauth neq "">
    But that's no better.
    Why on earth is that cfif always executing?  If I dump session.loginauth when a user's not logged in, I get nothing.

    BreakawayPaul wrote:
    Well here's the thing.  When a user logs in, I get an XML string from the authentication server, which I assign to session.loginauth.  I do this using a cfinvoke tag that calls a web service.
    When a user arrives without logging in, session.loginauth is null.
    That is what I mean by the blessing in disguise. The code is telling you otherwise: session.loginauth exists. Perhaps initialized in onSessionStart?
    What I want to do is only run the XML parse when session.loginauth contains the XML data from the authentication server, but it seems to run no matter what.
    My understanding is that if I cfparam something (even to "") it''s then defined, so isDefined won't work.  So I can either cfparam it to "" and test against "", or leave it alone and use IsDefined.  Right now neither seem to work.
    The code snippet I gave is a good workaround.
    The odd thing is, this code has been working for over 2 months and just started to fail yesterday morning.
    Right now my workaround is to wrap the cfinvoke and entire cfif block from my original post in a try/catch block, with the catch being empty.  This seems to avoid the error message for non logged in users.  But I still can't figure out why <cfif IsDefined("foo") runs when foo isn't defined.  Or at least I don't see how or where it's defined.
    Then it means that, yesterday morning, something happened to the code to make session.loginauth exist for unauthenticated users. As Sherlock Holmes said, "When you have eliminated the impossible, whatever remains, however improbable, must be the truth".
    I used to use StructKeyExists() all the time, but for some reason a bunch of the apps I used it on started throwing errors. Having all these dissimilar systems having to talk to each other is a real challenge.  A few years ago I had standalone systems using cflogin and had zero problems, but now I have to use these web services, and it's introduced elements that I can't control as well.
    Perservere. Software integration is always a challenge. On the plus side, it makes your system infinitely more scalable than cflogin would.

  • How to use ShowValue within a UIX/JSP page to display an active link?

    I am storing URL's in the DB and want to display them as active links on a UIX/JSP page. I thought that I had this working some time ago, but now it no longer works.
    Using <bc4juix:RenderValue datasource="ds1" dataitem="myTextField" /> will display "http://www.otn.oracle.com" as an inactive link using UIX/XML which is expected.
    Using <jbo:ShowValue datasource="ds1" dataitem="myTextField" /> will display an active link using if using BC4J/JSP, which is expected.
    However, I have not been able to do this using a UIX/JSP page.
    Is it possible to use ShowValue within a UIX/JSP page to display an active link?
    Thanks,
    Bill G

    Hi Juan,
    I've done the following and it does not work for me;
    --- snip ---
    <uix:form name="form1" method="GET">
    <bc4juix:Table datasource="ds1" >
    <uix:columnHeaderStamp>
    <uix:styledText textBinding="LABEL"/>
    </uix:columnHeaderStamp>
    <%--
    <jbo:AttributeIterate id="dsAttributes" datasource="ds1" hideattributes="UixShowHide">
    <bc4juix:RenderValue datasource="ds1" dataitem="<%=dsAttributes.getName()%>" />
    </jbo:AttributeIterate>
    --%>
    <bc4juix:RenderValue datasource="ds1" dataitem="FacilityDesc" />
    <bc4juix:RenderValue datasource="ds1" dataitem="LocationId" />
    <bc4juix:RenderValue datasource="ds1" dataitem="LocationDesc" />
    <%-- ** THE FOLLOWING DOES NOT DISPLAY ON THE BROWSE_EDIT_PAGE ** --%>
    <jbo:ShowValue datasource="ds1" dataitem="Notes" ></jbo:ShowValue>
    <%-- ** THE FOLLOWING DOES NOT DISPLAY ON THE BROWSE_EDIT_PAGE ** --%>
    <uix:rawText>
    <jbo:ShowValue datasource="ds1" dataitem="Notes" ></jbo:ShowValue>
    </uix:rawText>
    <%-- ** THE FOLLOWING DOES NOT DISPLAY ON THE BROWSE_EDIT_PAGE ** --%>
    <uix:contents>
    <uix:rawText>
    <jbo:ShowValue datasource="ds1" dataitem="Notes" ></jbo:ShowValue>
    </uix:rawText>
    </uix:contents>
    --- snip ---
    Bill G...

  • How can I connect to the database using ODBC within excel.

    Hi,
    How can I connect to the database using ODBC within excel and just refresh the data when needed.
    Thanks,
    Priyanka
    Edited by: user554934 on Jun 9, 2009 2:53 AM

    This is NOT an APEX relevant question, try posting it in the SQL/PL/SQL Forum..
    Thank you,
    Tony Miller
    Webster, TX

  • Why can't I use links within my email messages? When a link is clicked, nothing happens--it doesn't go to that specific website.

    Why can't I use links within my email messages? When a link is clicked, nothing happens--it doesn't go to that specific website.

    HI Ana ...
    I had FB working again two days ago, and yesterday in mid-serve Safari just "couldn't find the server" once more...
    That's a different issue...
    First, if you can just use English, open System Preferences > Language & Text then select the Language tab. Drag English to the top of the list then restart your Mac.
    Now for the server issue. Try using Open DNS. That shold help the "couldn't find the server" issue...
    Open System Preferences / Preferences then select the Network tab. Click the Advanced tab then click the DNS tab.
    Click +
    Enter these numbers exactly as you see them here.
    208.67.222.222
    Click +
    208.67.220.220
    Then click OK.
    Try accessing Facebook on Safari now.

  • How to use bash within sqlplus?

    How to use bash within sqlplus?
    meaning I am doing something like this to look for files within a particular directory with some condition.
    N=0
    for i in $(find . -path \*/waiting/* -type f -not -name "SS*" -mmin +120 -print) ; do
    testarray[$N]="$i"
    echo "$i"
    let "N= $N + 1"
    done
    Output from above script is as follows:
    /d1/d2/d3/d4/waiting/abcd.txt
    /d1/d2/d31/d42/waiting/pqrs.txt
    /d1/d2/d32/d43/waiting/xyz.txt
    And now I want to input this data into database with help of insert.
    and here is the little pl/sql block to insert the data with looping thing.
    sqlplus $CONNECT <<-EOF
    DECLARE
    Counter integer :=1;
    BEGIN
    WHILE Counter <= ${no_of_files} LOOP
    INSERT INTO stuck_files(COL_DATE,SER_NAME,TYPE_FILE,FILENAME,FILE_STATUS) VALUES (sysdate,'pqrs','pqrs','pqrs','pqrs');
    Counter := Counter + 1;
    END LOOP;
    END;
    commit;
    exit;
    EOF
    Mapping is as follows:
    COL_DATE,SER_NAME,TYPE_FILE,FILEFILENAME,FILE_STATUS
    sysdate,d3,d4,abcd.txt,waiting
    sysdate,d31,d42,pqrs.txt,waiting
    sysdate,d32,d3,xyz.txt,waiting
    any idea how to do that?
    Edited by: user9274197 on Apr 28, 2013 5:09 PM

    user9274197 wrote:
    How to use bash within sqlplus?
    meaning I am doing something like this to look for files within a particular directory with some condition.
    N=0
    for i in $(find . -path \*/waiting/* -type f -not -name "SS*" -mmin +120 -print) ; do
    testarray[$N]="$i"
    echo "$i"
    let "N= $N + 1"
    done
    Output from above script is as follows:
    /d1/d2/d3/d4/waiting/abcd.txt
    /d1/d2/d31/d42/waiting/pqrs.txt
    /d1/d2/d32/d43/waiting/xyz.txt
    And now I want to input this data into database with help of insert.
    and here is the little pl/sql block to insert the data with looping thing.
    sqlplus $CONNECT <<-EOF
    DECLARE
    Counter integer :=1;
    BEGIN
    WHILE Counter <= ${no_of_files} LOOP
    INSERT INTO stuck_files(COL_DATE,SER_NAME,TYPE_FILE,FILENAME,FILE_STATUS) VALUES (sysdate,'pqrs','pqrs','pqrs','pqrs');
    Counter := Counter + 1;
    END LOOP;
    END;
    commit;
    exit;
    EOF
    Mapping is as follows:
    COL_DATE,SER_NAME,TYPE_FILE,FILEFILENAME,FILE_STATUS
    sysdate,d3,d4,abcd.txt,waiting
    sysdate,d31,d42,pqrs.txt,waiting
    sysdate,d32,d3,xyz.txt,waiting
    any idea how to do that?
    Edited by: user9274197 on Apr 28, 2013 5:09 PMhttp://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:439619916584
    Cheers,

  • Using variables within GETurl

    Having issues with getting a simple script working...
    I've created a 'flashvars' tag in my embed code (aid=test), which I simply wish to add to the end a GetUrl statement, contained in within a button (which is on the first level of the flash movie). This is the code I've added to the button...
    on (release) {
        getURL("http://www.platinumselect.com?id="+aid);
    But this doesnt seem to work!? Is there anything else I need to do?
    Thanks in advance! (p.s. using actionscript 2.0)

    Where are the 3 places?? I've got it in two at the minute.
    Date: Tue, 10 Nov 2009 07:53:55 -0700
    From: [email protected]
    To: [email protected]
    Subject: Using variables within GETurl
    in as2, there is no LoaderInfo class and you don't need to do anything in flash to parse the flashvars.
    but, as i mentioned in a duplicate post, you do need to define your flashvars in 3 places in your embedding html file.  failure to do that is the most common reason for a problem with flashvars.
    >

  • Using SMC within a LDOM

    When we fire off smc with a ldom it doesn't load fully. The start up screen pops up but the option to connect to the system doesn't load. Any ideas??
    Using zfs within ldom also.

    How about some code snippets? from what you say I can't see a problem.
    Cheers
    DB

  • Using isDefined for a dynamic struct?

    I know how you can check for a defined variable or object using isDefined("myVar"), but I have a struct that can have varying properties. While I can explicitly write out the "myStruct.myProperty" checks in quotes for this method, I'd like to put these into a function where a variable is passed into it.
    Is this possible? Basically, I'm populating form fields and some fields may not be defined yet. Thoughts? Thanks.
    Ryan

    Thanks for the help BTW. I'm still new to CF, I'm more of a .net guy.
    Basically, I have this. It's a form that edits and adds bios for members:
    objStatement = objConnection.PrepareStatement("select bio_first_name, bio_last_name from cpppeBios where bio_id = ?");
    objStatement.setInt(1, Int(FORM.edit_bio_id));
    objResults = CreateObject("java", "coldfusion.sql.QueryTable").Init(objStatement.ExecuteQuery());
    EditBio = structNew();
    EditBio = objResults;
    ....and, I have input fields down below...
    <input type='text' value='' />
    I use the same form for adding and editing bios. What is the best approach for handling populating of these fields when the EditBio object can be null or contain data. I would access the data using EditBio.bio_first_name, etc.
    Thanks again.

  • The buttons in main the vi get locked after opening a vi reference in a subpanel and using buttons within the subpanel.

    I am trying to open a reference to a vi in the subpanel of the main vi. However after the vi opens in the subpanel and after pressing a few buttons in the subpanel the buttons in the main vi get locked, i.e. I can't even close the main vi or control anything else. Is there any way how I can avoid this happening?

    > The buttons in main the vi get locked after opening a vi reference in
    > a subpanel and using buttons within the subpanel.
    >
    > I am trying to open a reference to a vi in the subpanel of the main
    > vi. However after the vi opens in the subpanel and after pressing a
    > few buttons in the subpanel the buttons in the main vi get locked,
    > i.e. I can't even close the main vi or control anything else. Is there
    > any way how I can avoid this happening?
    This is most likely happening because in either the top or sub panel,
    there is an event structure that is queuing events, and is set to lock
    the panel until the events are handled, and because of the logic in the
    diagram, the events aren't being pulled from the queue.
    So, you have a deadlock. You are waiting
    on the panel. The panel is
    waiting on the diagram. And the diagram is waiting on something else.
    So, if there are indeed event structures involved, determine where in
    the diagram things are delaying. Also, if you do not need the panel to
    lock until the event is handled, you can change the setting in the
    events dialog on the structure. But the events will still be queued
    until the diagram starts executing.
    Greg McKaskle

  • Using groups within choice

    Is it impossible to use group within choice ?
    I am trying to do the following:
    <xs:group name = "attrib_val_group">
    <xs:sequence>
    <xs:element ref="attrib"/>
    <xs:element ref="value"/>
    </xs:sequence>
    </xs:group>
    <xs:group name = "attrib_attrib_group">
    <xs:sequence>
    <xs:element ref = "attrib"/>
    <xs:element ref = "attrib"/>
    </xs:sequence>
    </xs:group>
    <xs:element name="coroprate">
    <xs:complexType>
    <xs:choice>
    <xs:group ref="attrib_val_group"/>
    <xs:group ref="attrib_attrib_group"/>
    </xs:choice>
    </xs:complexType>
    </xs:element>
    The problem is that during parsing the parser shouts on:
    <coroprate>
    <attrib>..</attrib>
    <attrib>..</attrib>
    </coroprate>
    While the parser does accept:
    <coroprate>
    <attrib>..</attrib>
    <value>..</value>
    </coroprate>

    Modify group attrib_attrib_group.
    <xs:group name = "attrib_attrib_group">
    <xs:sequence>
    <xs:element ref ="attrib" maxOccurs="2" />
    </xs:sequence>
    </xs:group>

  • Using italics within Htmltext with embedded fonts

    hi there guys, I've been trying to use embedded fonts within my htmlText. However, it seems like it only shows the bold/normal fonts and it ignores the italics. The italics part of htmlText shows up as normal weight/ normal style font.
    Here's what I am doing (am i doing anything wrong?):
    I embed my fonts within a .css file:
    @font-face {
        src: local("Verdana");
        fontFamily: myFontFamily;
        advancedAntiAliasing: true;
        fontWeight: bold;
        fontStyle: italic;
    @font-face {
        src: local("Verdana");
        fontFamily: myFontFamily;
        advancedAntiAliasing: true;
        fontWeight: normal;
        fontStyle: italic;
    @font-face {
        src: local("Verdana");
        fontFamily: myFontFamily;
        advancedAntiAliasing: true;
        fontWeight: normal;
        fontStyle: normal;
    @font-face {
        src: local("Verdana");
        fontFamily: myFontFamily;
        advancedAntiAliasing: true;
        fontWeight: bold;
        fontStyle: normal;
    Then i use it within this Text component:
      <mx:Text width="100%" color="blue" fontFamily="myFontFamily" f>
            <mx:htmlText>
                <![CDATA[
                    <font color="#000000" size="10">This text is 10 point black, <i>italic</i>, and <b>bold</b>.</font>
                ]]>
            </mx:htmlText>
        </mx:Text>

    http://cookbooks.adobe.com/post_Using_rich_HTML_text_formatting_with_embedded_font-16974.h tml

  • How to use SelectOneRadio within a DataTable

    Hi,
    I have a requirement to have a radio button for each row in the datatable. It is to enable selecting one row(only one row) from the table and proceed to the next page. The table should look like
    o Name1 address1 city1 state1
    o Name2 address2 city2 state2
    o Name3 address3 city3 state3
    o Name4 address4 city4 state4
    Next>>
    The data structure I have is a collection on objects of type person.
    Class person
    String id;
    String name;
    String address;
    String city;
    String state;
    getters and setters
    I tried to use SelectOneRadio within a Column, but that didnt help. As obvious it treats each rows radio button as a seperate radio group.
    <h:datatable var="person" value="#{personList}>
    <h:column>
    <h:selectOneRadio>
    <f:selectItem itemValue="#{person.id}"/>
    </h:selectOneRadio>
    </h:column>
    <h:column>
    <h:outputText value="#{person.name}"\>
    </h:column>
    </h:datatable>
    I am new to JSF. I searched thru some JSF websites and book, but couldnt find a solution. Can someone help me solve this.
    Thanks in advance
    Rani

    Hi,
    after some time probing into this issue I think none of the many proposed sollutions really solves the underlying problem: Working around the issue becomes much to complicated for JSFs stated design goal of easing development. Certainly for such a common case scenario no workaround should be neccessary, especially given the fact that JSTL is easily able to model this without the need for workarounds!
    In my opinion JSF TagLib implementations should attempt to solve this in a coming version.
    One part of the sollution might be to make <f:selectItem> search it's parent element recursively, i.e. allow the expected container element to be the nearest direct or indirect parent that's suitable. This would allow developers to envelope a <h:dataTable> tag with a <h:selectOneRadio> element. Any <f:selectItem> element inside would therefore be part of a single choice radio button selection, regardless of them being distributed over multiple rows or columns.
    Another part of the sollution might be to allow <h:selectOneRadio> and similar tags to be substitutes for <h:column> tags inside tables. This way a complete column of radio buttons could be used to chose a single value, thereby allowing multiple columns of radio buttons to choose multiple values within the same table.
    Please forward this suggestion for enhancement in kind to the expert group working on the further development of the JSF taglibs. I guess many people besides me already use it as a classical example of complications using JSF during lectures about the tomic, and at least in this case the problem seems completely solvable.
    Kind regards,
    Sascha Baumeister
    software architect, university lecturer and former JCP spec lead JSR086

  • Is there a way to run IDS within Websphere to recieve messages through JMS, then invoke Documaker?  Configuring the IDS client to use JMS within websphere seems pretty straight forward, but I cannot find information on running IDS as a server to invoke Do

    Looking to move the maintenance of our IDS instances which drive Documaker MRLs from the Unix command line to within a container ( Websphere ).  Using the IDS Java client with JMS is pretty easy.  I cannot see how I would be able to get an IDS server running within Websphere.

    IDS is not designed to run in WebSphere or any other J2EE container. It is a standalone Java application that uses native code, allows to run custom code, reads and writes files on disk, starts other processes, etc. and as such is not exactly suitable to run in J2EE. Most of such actions are not enabled (at least by default) in J2EE due to security concerns. You could run it as a service on Windows or setup to start automatically on Unix.
    What exactly do you want to achieve by it being in J2EE container? Perhaps there are other ways to do the same thing?

  • How to use List within javaFX(*.fx) script?

    How to use java.util.List within javaFX(*.fx) script?
    The following is my code in Java
    PDBFileReader pdbreader = new PDBFileReader();
              pdbreader.setPath("/Path/To/PDBFiles/");
              pdbreader.setParseSecStruc(true);// parse the secondary structure information from PDB file
              pdbreader.setAlignSeqRes(true);  // align SEQRES and ATOM records
              pdbreader.setAutoFetch(true);    // fetch PDB files from web if they can't be found locally
              try{
                   Structure struc = pdbreader.getStructureById(code);
                   System.out.println("The SEQRES and ATOM information is available via the chains:");
                   int modelnr = 0 ; // also is 0 if structure is an XRAY structure.
                   List<Chain> chains = struc.getChains(modelnr);
                   for (Chain cha:chains){
                        List<Group> agr = cha.getAtomGroups("amino");
                        List<Group> hgr = cha.getAtomGroups("hetatm");
                        List<Group> ngr = cha.getAtomGroups("nucleotide");
                        System.out.print("chain: >"+cha.getName()+"<");
                        System.out.print(" length SEQRES: " +cha.getLengthSeqRes());
                        System.out.print(" length ATOM: " +cha.getAtomLength());
                        System.out.print(" aminos: " +agr.size());
                        System.out.print(" hetatms: "+hgr.size());
                        System.out.println(" nucleotides: "+ngr.size()); 
              } catch (Exception e) {
                   e.printStackTrace();
              }The following is my code in JavaFX(getting errors)
    var loadbtn:SwingButton = SwingButton{
        text:"Load"
        action: function():Void{
            var pdbreader = new PDBFileReader();
            var structure = null;
            try{
                structure = pdbreader.getStructure(filepath.text);
                List<Chain> chains = structure.getChains(0);
                foreach (Chain cha in chains){
                        List < Group > agr = cha.getAtomGroups("amino");
                        List < Group > hgr = cha.getAtomGroups("hetatm");
                        List < Group > ngr = cha.getAtomGroups("nucleotide");
            } catch (e:IOException) {
                e.printStackTrace();
        };I'm using Netbeans 6.5 with JavaFX
    (PDBFileReader, Chain, Structure etc are classes from my own package, already added to the library folder under the project directory)
    Simply put, How to use List and Foreach in JavaFX?

    We can not use Java Generics syntax in JavaFX. But we can use Java Collection classes using the keyword 'as' for type-casting.
    e.g.
    import java.util.LinkedList;
    import java.util.List;
    import javafx.scene.shape.Rectangle;
    var outerlist : List = new LinkedList();
    var innerlist : List = new LinkedList();
    innerlist.add(Rectangle{
        width: 10 height:10});
    innerlist.add(Rectangle{
        width: 20 height:20});
    outerlist.add(innerlist);
    for (inner in outerlist) {
        var list : List = inner as List;
        for (element in list) {
            var rect : Rectangle = element as Rectangle;
            println("(width, height)=({rect.width}, {rect.height})");
    }

Maybe you are looking for