Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 16 Next »

[14:30:12 CDT(-0500)] <EricDalquist> drewwills: there?

[14:45:14 CDT(-0500)] <cwaymire> EricDalquist: hey got a quick question for you.

[14:45:19 CDT(-0500)] <EricDalquist> ok

[14:46:35 CDT(-0500)] <cwaymire> i've got a portlet that I added a Spring MVC controller into. I noticed that when calls come into that controller they have neither an active HttpSession nor does the request object contain a remote username.

[14:46:49 CDT(-0500)] <EricDalquist> this is a servlet controller?

[14:46:53 CDT(-0500)] <cwaymire> in this instance its important that I be able to get the user name

[14:46:59 CDT(-0500)] <cwaymire> yeah. standard spring mvc controller

[14:47:17 CDT(-0500)] <EricDalquist> so for the session to exist you need to make sure that the tomcat instance has emptySessionPath set to true

[14:47:24 CDT(-0500)] <EricDalquist> or whatever the TC7 version of that is

[14:47:31 CDT(-0500)] <EricDalquist> there will never be a remoteUser though

[14:47:33 CDT(-0500)] <cwaymire> let me double check my setting

[14:47:43 CDT(-0500)] <EricDalquist> that servlet is being directly accessed by the client

[14:47:49 CDT(-0500)] <EricDalquist> the portal has zero control over it

[14:48:00 CDT(-0500)] <EricDalquist> so none of the portal user's "state" is available

[14:48:07 CDT(-0500)] <EricDalquist> and in fact the session will only exist

[14:48:16 CDT(-0500)] <EricDalquist> if you have previously accessed a portlet in the same webapp

[14:48:19 CDT(-0500)] <EricDalquist> and that portlet created a session

[14:48:43 CDT(-0500)] <cwaymire> which is the case. are there any tricks to getting the username of the authenticated user?

[14:49:39 CDT(-0500)] <EricDalquist> the only way

[14:49:48 CDT(-0500)] <EricDalquist> is for the user to visit the portlet first

[14:49:57 CDT(-0500)] <EricDalquist> the portlet stores the username in the application scope in the portlet session

[14:50:01 CDT(-0500)] <EricDalquist> then the servlet can see that value

[14:50:10 CDT(-0500)] <EricDalquist> if the servlet is the first point of contact though

[14:50:10 CDT(-0500)] <EricDalquist> no

[14:50:12 CDT(-0500)] <EricDalquist> there is no way

[14:51:14 CDT(-0500)] <cwaymire> The portlet (Attachments) will always be there. It will basically be a hidden div on the page. An interaction in another portlet will cause a lightbox to display allowing the user to select a file to upload via a multipart POST.

[14:51:51 CDT(-0500)] <cwaymire> but I need to know who the user was that submitted the upload.

[14:52:13 CDT(-0500)] <EricDalquist> yeah they would need to visit the portlet first

[14:52:17 CDT(-0500)] <EricDalquist> why not have them upload to the porlet

[14:52:26 CDT(-0500)] <EricDalquist> portlets can deal with uploads via action and resource urls

[14:53:49 CDT(-0500)] <cwaymire> the idea was that the Attachments portlet would basically be an invisible portlet that wasnt rendered but would expose a global javascript api that would open up a lightbox div on the page allowing you to upload a file. So any portlet that wants to use attachments can simply call the global js method and give it a callback method. When the upload is done the callback method is executed with some result data.

[14:54:28 CDT(-0500)] <EricDalquist> so you are 'uploading" to the javascript?

[14:54:55 CDT(-0500)] <EricDalquist> or is the attachment stored somewhere that other portlets could potentially reference/access?

[14:55:51 CDT(-0500)] <cwaymire> the javascript makes an ajax call to submit the file to the controller which creates some database rows and will store the file on the filesystem.

[14:56:15 CDT(-0500)] <EricDalquist> ok

[14:56:16 CDT(-0500)] <cwaymire> the idea is any portlet can upload an attachment and then later reference that attachment. right now the functionality is going to be pretty limited

[14:56:26 CDT(-0500)] <EricDalquist> so why the servlet?

[14:56:34 CDT(-0500)] <EricDalquist> the portlet could do that competely within the portlet API

[14:56:46 CDT(-0500)] <EricDalquist> the attchment portlet renders in a hidden div

[14:56:55 CDT(-0500)] <EricDalquist> the JS that is written out includes a portlet resource url

[14:57:16 CDT(-0500)] <EricDalquist> the JS "upload attachment" api POSTs the file upload to the resource url

[14:57:32 CDT(-0500)] <EricDalquist> which accepts the upload, stores it, writes to the db and returns some JSON with the DB key to the new upload

[14:57:39 CDT(-0500)] <EricDalquist> which the other portlet can then use/store/etc

[14:57:57 CDT(-0500)] <cwaymire> The part I had trouble with was getting it to work on a ResourceMapping

[14:58:36 CDT(-0500)] <cwaymire> it didnt seem to send the right parameters across to the mapping

[14:59:07 CDT(-0500)] <cwaymire> i took the working code from the mvc controller and put it under a ResourceMapping and it didnt like the params.

[14:59:12 CDT(-0500)] <EricDalquist> what do you mean?

[14:59:22 CDT(-0500)] <EricDalquist> ah, do you have an example of that?

[14:59:50 CDT(-0500)] <cwaymire> yeah. i can gist it if you want

[14:59:53 CDT(-0500)] <EricDalquist> sure

[15:01:21 CDT(-0500)] <cwaymire> https://gist.github.com/anonymous/5207946

[15:01:21 CDT(-0500)] <cwaymire> https://gist.github.com/anonymous/5207952

[15:01:24 CDT(-0500)] <cwaymire> first one is the mvc controller

[15:01:28 CDT(-0500)] <cwaymire> second is a portlet resource mapping

[15:01:54 CDT(-0500)] <cwaymire> when I attempted to use the resource mapping I got an error saying org.springframework.web.portlet.bind.MissingPortletRequestParameterException: Required MultipartFile parameter 'qqfile' is not present

[15:01:55 CDT(-0500)] <EricDalquist> ok

[15:02:18 CDT(-0500)] <EricDalquist> but it works for the action request version of that?

[15:02:45 CDT(-0500)] <cwaymire> the mvc controller using a RequestMapping works

[15:03:06 CDT(-0500)] <EricDalquist> just out of curiousity

[15:03:06 CDT(-0500)] <cwaymire> at first I tried using an ActionMapping/RenderMapping pair but I need/want to return json

[15:03:12 CDT(-0500)] <EricDalquist> can you try doing this one: https://gist.github.com/anonymous/5207946

[15:03:23 CDT(-0500)] <EricDalquist> but change the ActionReq/Res to ResourceReq/Res

[15:03:35 CDT(-0500)] <EricDalquist> and use a resourceurl instead of an actionurl to call it

[15:03:41 CDT(-0500)] <EricDalquist> just to see if that makes any difference

[15:03:42 CDT(-0500)] <EricDalquist> if not

  • No labels