E-com DevBlog Spider-ball-vacuum

3Dec/080

A quick post (based on a google search) about WCParam

I was reviewing my logs and noticed that two people happened to hit the site looking for an explanation on how to add a parameter to WCParam.  So I thought I'd take a minute or two and write up a  quick example using JSTL.

What you need to do is add the parameter in your c:url tag as a parameter when you define it. Let's say that I have a value that I am taking from a c:forEach loop (with a var="items"), we'll call it 'otherId' (since I'm going to pass this through the location/address-bar). I am also going to pass a langId (language code), a storeId (we're all about commerce), a catalogId (yep, we like to sell things), and finally my otherId. Using the code below (and yes I'm skipping setting up your command or whatever you are passing to) I can set up a quick c:url tag with my custom parameter in it that I can then access through the ${WCParam.otherId} on the page that I go to.

You must be using the 'c' tag lib for this to work, so don't forget to include that on your page, here we go.

?View Code HTML4STRICT
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 
<c:url var="myURL" context="${CommandContext.webpath}" value="/mycmd">
   <c:param name="langId" value="${langId}" />
   <c:param name="storeId" value="${WCParam.storeId}" />
   <c:param name="catalogId" value="${WCParam.catalogId}" />
   <c:param name="otherId" value="${items.otherId}" />
</c:url>

And that, in a quick nut shell is how you get a variable accessible through your WCParam. Remember, WCParam is pretty much the same as saying, 'grab it from the location/address/url-bar'.

Feel free to drop corrections and comments (and yes I realize that my code box says HTML4STRICT, until it supports JSP code, HTML4STRICT is what you get).

Print This Post Print This Post