Does anyone know how to use SitePublisher Controller to dispatch request and pass parameters/attributes between two .page?
I use the default action class 'ContextRedirectForwardAction', but it doesn't work.
what does URL mean under the background of SitePublisher/LiveSite? is it a .page or something?.
I suggest you look at the SP Dev guide -- there are some very good examples of Controllers. Usually the easiest way to pass parameters between two pages would be to tack on whatever parameters you have on the request itself. There are may be other options depending on your requirements.
What you mean by it doesn't work? Are you getting any errors? Have you checked the servletd log file?
[9/8/09 11:00:09:436 HKT] 00000031 RuntimeRender I com.interwoven.livesite.runtime.rendering.RenderingManager getRequestContext EVENTS[0ms]("RenderingManager.getRequestContext"){ [Creating RequestContext]=0 [Setting up RequestContext]=0 [Setting up OpenSessionsInViewHelper]=0}[9/8/09 11:00:09:437 HKT] 00000031 RuntimeContro I com.interwoven.livesite.runtime.controller.RuntimeController execute EVENTS[0ms]("execute: com.interwoven.livesite.runtime.controller.RuntimeController@f5635ae[object=com.interwoven.livesite.LoginController,method=public com.interwoven.livesite.common.web.ForwardAction login(com.interwoven.livesite.runtime.RequestContext,),scope=,parameters={}]"){ [Build parameters]=0 [Get POJO controller object]=0 [Execute POJO controller method]=0}[9/8/09 11:00:09:439 HKT] 00000031 RuntimeRender I com.interwoven.livesite.runtime.rendering.RenderingManager doSetupRenderingObjects EVENTS[2ms]("RenderingManager.doSetupRenderingObjects: /B2B_TEST/a.page"){ [doSetupSessionsInView]=0 [doSetupSite]=0 [doValidateSite]=0 [doSetupUserSession]=0 [doSetRefererHistory]=0 [doSetUserAgent]=0 [doSetupUserProfile]=0 [doLoginCookie]=0 [doUrlAliasCheck]=0 [doSetPageName]=0 [doValidatePage]=0 [doSetupPage]=0 [doCheckLoginPage]=0 [executeSitePreControllers]=0 [executePagePreControllers]=0 [executeComponentControllers]=2 [executePagePostControllers]=0 [executeSitePostControllers]=0 [doFinishUserSession]=0 [doSetClickStream]=0 [doCleanupSessionsInView]=0}[9/8/09 11:00:09:440 HKT] 00000031 RuntimeRender I com.interwoven.livesite.runtime.rendering.RenderingManager render EVENTS[3ms]("RenderingManager.render: /B2B_TEST/a.page"){ [preRender]=0 [isExcludeGoal]=0 [renderPageGoal]=3 [postRender]=0}
Could you please point these good examples for me? I didn't find an controller example to pass parameters between two page. thanks.
You'll have to use the dev guide and some basic web / Java knowledge and derive to your solution. You could leverage request / session to pass parameters/variables between pages.
Can you install HttpWatch or FoxHttp (or something to log the URL path). It is hard to figure out where you are being redirected based on limited information provided in this post.
Thanks for your reply. Forget the above confused information. I want to pass attributes/parameters between two pages with only controllers and external calls? For example:I have page a, its link is http://www.mydomain.com/appname/a.page, and there is a form on page a. There is an external call on page b. after submitting page a, I want to redirect to page b and get the attributes in the external call of page b.do you have any ideas?
Again, some of the basics of what you are asking for is outlined in the SP Dev guide + some will have to be derived to with Java / Web (HttpRequest) knowledge. I would say look at the Controller / External mechanism and then look up the RequestContext class in the LS API. You should try some samples from there and post your specific questions.
Thanks. maybe i made a mistake. what if I want to display the attributes on page b, not the external call. is there something i can do on the component of page b? like get the attributes by some variables $CONTEXT{*}, $URL_PREFIX?
Before you go look at the $CONTEXT token, have you looked at the RequestContext in the LS API doc itself? Look at that first and then you can either use External and / or $CONTEXT -- they are both different ways of accessing the "RequestContext".
From your word, i can guess that my question has an answer, but I don't know what it is.if you can say a liitle more detail, that will be help.Also, I do look at all the guides i can find, but i didn't find the answer, that is why I am asking here. I don't think I need you to remind me to look at the guides/APIs.
It is absolutely doable. Forget LS for a moment. Do you have some rough idea about how could this be achieved in a simple JSP framework? Fundamentally the approach is very similar. You use either request or session and set attributes in there. With that said, from Page A you'll have a Controller that will set parameter X either in the request or session and then forward to Page B. On Page B you'll need an External (or alternatively $CONTEXT token may or may not suffice) that'll retrieve parameter X either from the request or session (based on how and where you set it). Since you have read the docs, I would say implement a simple Controller on Page A and have it forward your request to Page B and initially dont worry about passing anything just yet. That would be your starting point. There are exact code samples for this in the SP Dev guide. Let's get to this point first.Once you have done this then try what I just mentioned above to pass parameters. Remember when you try to pass parameters: you have access to RequestContext as well underlying ServletRequest and the HttpSession. If you run into issues then post your specific questions. Basic solution will probably take 2 Java classes with less than 10 lines of code in each class. I have done this many times over and I'll be glad to assist if you actually try something and post your code/errors.
Thank you very much. This is really nice. And I think i have tried what you said, but failed. Please help me out. I will post my code here. There are two component: login and session. in login component, there is a form with user name input and a login controller. in session component, there is an external call. these two components will be put on two different pages. Once user name is input and form submit, I want to get the user name in the session external call. I can get the user name from usersession and httpsession, but not context and request, am I doing it in the right way?is it because I use URLRedirectForwardAction and they are not the same request/context after submit?
public ForwardAction login(RequestContext context) throws IOException { context.getSession().setAttribute("userName", "John Doe"); ForwardAction forwardAction = new URLRedirectForwardAction(context, "path/to/second-page"); return forwardAction;}
protected Document getSessions(RequestContext context) throws Exception{ Document doc = Dom4jUtils.newDocument(); String userName = context.getSession().getAttribute("userName"); Element root = doc.addElement("sessions"); Element userNameElement = root.addElement("User").set.setText(userName); return doc;}
Now we are talking -- this is a good start. Let me ask you this first: are you able to forward to the next page with the Controller from the first page? If not then you need to get that to work first -- just simple redirect/forward and don't worry about parameters. If you have tha tworking then something like this should set you on the right path:
Datum
External/Parameters
Name
All,This thread is getting confusing, but I want to say for Eric and possibly others who might search and find this thread:I recommend using component parameters to communicate from components on one page to components on another, wherever that is possible. Any Datum in the External/Parameters section will be automatically set with the request query parameter with a matching Name.If that's not possible or not the cleanest design, then yes, controllers can be used, but I personally avoid controllers if there's a way to do it with components or component externals, since well-designed components are more reusable than (even well-designed) pages.Stokes.
Yes, I can forward to the next page with the controller from the first page and I can get the parameters from context.getSession()(I think the UserSession class use httpsession to pass parameters) and httpsession in the next page. I think the external call i attached has shown the usersession works well, it is the same as the code you write.But I want to use httprequest to pass the parameters, is it possible?
Hi vpatelNo response?