persist value over a http post request.

Okay, I see what you are trying to do. Thanks for the clarification.
I'm not sure why the persistVariables() call at the top of your view
isn't allowing you to pass your name_art variable to your form
processing event. Let me just confirm a few things with you:

1) the syntax you are using is <cfset persistVariables("name_art") />
2) if you simply do a <cfoutput>#rc.name_art#</cfoutput> in your form
view, you get the expected output
3) when it gives you the error message "Element NAME_ART is undefined
in RC", is it referring to the code in your handler or your view (what
is the file and line number it gives you?)?

1) Yes this is true
2)Yes I get the expected output
3) The error is occurring in my handler....on this line of code

  <!---If user is trying to submit the current artist name--->
    <cfif rc.name is "#rc.name_art#">

WHERE rc.name is a form field which contains the new artist name the
user is submitting, and #rc.name_art# is meant to be the variable
coming from the <cfset persistVariables("name_art") /> at the top of
my view "edit.cfm"

Thanks

You said:

3) The error is occurring in my handler....on this line of code

    &lt;\!\-\-\-If user is trying to submit the current artist name\-\-\-&gt;
            &lt;cfif rc\.name is &quot;\#rc\.name\_art\#&quot;&gt;

Where is this line of code in your handler. Is it in the setArtist()
method? Because I don't see it in the handler code that you provided
earlier.

Yes, sorry, I may be confusing you...

I initially ripped the code

   <!---If user is trying to submit the current artist name--->
               <cfif rc.name is "#rc.name_art#">

validation code for the set artist handler....

WIth the validation the handler looks like this

<!---Edit Artist Action--->
        <cffunction name="setArtist" output="false"
returntype="void">
                <cfargument name="EVENT" type="any">
                <!---request to reference collection--->
                <cfset var rc = Event.getCollection()>

                <!---Prepare logic--->
                <cfset artist = createObject
('component',"myapp.model.mdl_artists")>

               <!----Validation------------------------------->
               <!---If user is trying to submit the current artist
name--->
               <cfif rc.name is "#rc.name_art#">
               <!----Send back to artist home page with error
message----->
                Appropriate code goes here
               <!----Otherwise, enter the new artistname into the
database--->
                <cfelse>

                <cfset rc.qrySetArtist = artist.setArtistData
(nameArt=rc.name,oldNameArt=rc.name_art)>
                <!---Reroute back to edit artist page--->
                <cfset setNextRoute("artist/#rc.name#/edit")>
               </cfif>

                Thanks

Just wondering if anyone had any further ideas?

Or maybe there is something in coldbox that replicates the
CGI.HTTP_REFFERER variable?

try persisting the value in your edit *action* (action that has the
form) instead of the view your event handler is rendering. You still
have scope to your collection from your handler...

So I'm assuming you have a handler named "artists" with an action
edit? define your persistence in the action!

hope that helps.

Hi there, thanks for the response....Im a bit confused by the response
however...

I have an edit artist method in the artists handler, which is where
the form gets sent to...the code is below...

<!---Edit Artist Action--->
        <cffunction name="setArtist" output="false"
returntype="void">
                <cfargument name="EVENT" type="any">
                <!---request to reference collection--->
                <cfset var rc = Event.getCollection()>
                <!---Prepare logic--->
                <cfset artist = createObject
('component',"myapp.model.mdl_artists")>
                <cfset rc.qrySetArtist = artist.setArtistDataThe
(nameArt=rc.name,oldNameArt=rc.name_art)>
<!---Reroute back to edit artist page--->
                <cfset setNextRoute("artist/rc.name/edit")>

The form is in a view called editartist....which is displayed by a
handler method called editartist..

The form posts to the setArtist method through an exit handler...as
shown below..

<form name="setArtName"
    action="#rc.xehArtEdit#"
    method="post">
etc etc etc

</form>

Now the variable that i am trying to persist is in the url of the
editArtist page.....so route = "editArtist/name_art" works like this
editArtist/oasis.....

Now are you advising that I persist the name_art variable in the
handler method called editartist instead of the editArtist view?
because I tried this and it still didnt work...

I get the error message

The name_art variable only seems to work, if I use a hidden form
field, as so

<!---Hidden form field--->
<input name="name_art"
     type="hidden"
     value="#rc.name_art#" />

Thanks

If I am reading correctly, you are misunderstanding what it means to persist a variable across different requests. Let me make sure I have this right…

Step 1: Load the Edit Artist page (form)

myapp.com/editArtist/Oasis
displays a form to edit the various information about the artist (‘Oasis’ in this example)

Step 2: Set Artist Data (form action “page”)

saves the updated artist information to the database

Is that correct?

If yes, then the only way to get the artist variable from Step 1 to Step 2 is to either use a hidden form field (as you’ve discovered) or to add it to the request string when submitting the form (e.g. ).

The persistVariables() method is used when using either the setNextEvent() or setNextRoute() method to tell ColdBox to move the request along to another event. While it is technically a separate request, to the user it appears as one single request.

persistVariables() cannot magically take a variable at the end of one request (e.g. when the form is displayed) and make it miraculously appear on the other side of another request (e.g. when the form is submitted).

Yes that is correct..

Ok, i thought there was a way of doing this using the persist variable
function....

I will use your suggested method "<form
action="#rc.xehArtEdit#?name_art=#rc.name_art#"" instead..

Glad I cleared this up

Thanks for your time and assistance

OK. No problem. Glad to help.

To add one more bit of info, if you have a route setup for setArtist/name_art, then you can also use and it will pass along the artist name in a “pretty URL” format.

cool...will do it that way

thanks