Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mason component params from http request

Status
Not open for further replies.

philote

MIS
Oct 2, 2003
861
US
I'm having some problems using Mason to get parameters from an http request. It works fine for params with only one value, but I have a list of checkboxes all with the same name, so I want to be able to get the values for each one checked. I can do it fine if I know multiple values will be checked OR can do it if I know only one value will be checked. In other words, how do I properly get all the values when either one or multiple check boxes can be checked?

 
Nevermind, I got it working. Not sure what I did wrong before but what I had to do was declare an array with the name of the checkboxes in the %args section of the component. I think my problem was happening when passing this array to my subcomponent due to some array/arrayref confusion on my part.

 
Yea these suck in mason. Its more perl's fault then mason's fault.

If you get a single item back its a scalar

If you get multi items back its an array

If you access teh scalar as an array perl barks at you.

I always end up checking to see if the 'expected array' is really a scalar and if so passing it into an array. That way all my subsequent code just deals with an array.

 
And if you define an argument as an array and there's only one value for that parameter it's just a one-element array.

I'm still not sure what I did wrong but it's working now. I just started learning Mason and am working on a project for our intranet that needs to be finished soon. So I've been rushing a bit and therefore making some careless mistakes, like this was.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top