Spring Portlet ResourceRequest Change

Spring Portlet made a change to the way portlets return resource requests.  They changed the default behavior of DispatcherPortlet when handling resource
requests to use PortletRequestDispatcher.forward instead of PortletRequestDispatcher.include; JIRA issue here — SPR-9876.  I’m indifferent about the change.  It seems more people use the ResourceRequest with the .forward, so its good for them I guess.  I mostly use resource requests with small custom jsps, so I use the .include.  But it doesn’t really matter to me aslong as they maintain compatibility, which they did.  If you set renderResourceViewViaInclude property to true(defaults as false) it should work the same as before.

Well, I can’t get my views to render through resource requests anymore after this change.  The only change that was supposed to be needed was adding an init-param into your portlet.xml, but even with that in place my views just return blank.

<init-param>
<name>renderResourceViewViaInclude</name>
<value>true</value>
</init-param>

Another person also suggested to set alwaysInclude to true on the InternalResourceViewResolver in the applicationContext, but that didn’t work for me either.

<bean id=”viewResolver” class=”org.springframework.web.servlet.view.InternalResourceViewResolver”>
<property name=”cache” value=”false”/>
<property name=”alwaysInclude” value=”true”/>
<property name=”viewClass” value=”org.springframework.web.servlet.view.JstlView”/>
<property name=”prefix” value=”/WEB-INF/jsp/”/>
<property name=”suffix” value=”.jsp”/>
</bean>

I’m still trying to figure out why this isn’t working.  Based on the git commit tied to the issue, it looks like aslong as renderResourceViewViaInclude is set to true then the dispatcher should call .include.  Is it not working as intended?  Or is renderResourceViewViaInclude not being set properly?

The culprit has been found! While talking with the person who made the JIRA issue and git commit, it looks like Spring never implemented the renderResourceViewViaInclude flag on DispatcherPortlet(and now rereading the last comment on JIRA I can see that they actually said they weren’t going to). So all resource requests were ALWAYS using .forward.  The fix?  You will have to subclass DispatcherPortlet and override doDispatch to use .include, or set up your own flag.

Hopefully Spring will actually put this the flag into the their portlet library so people won’t have to do this for every portlet that wants a review returned from a resource request.Talking with some other portlet developers, it seems I am in the minority of using resource requests to return views, they are mostly used to return pure json data.  It seems I either need to get with the times or I will have to use my subclassed DispatcherPortlet in all future portlets.

Ever Watched Something Come Back To Life?

I was remembering the Blue Like Jazz movie resurrection story the other day, I’m still blown away that we pulled it all off.

  • Donald Miller writes a well-received book called Blue Like Jazz: Nonreligious Thoughts on Christian Spirituality.  It gets pretty popular among 20/30-somethings for how personable Miller’s writing style is and his honest takes on Christianity.
  • Steve Taylor approaches Miller to make a movie out of Blue Like Jazz. They find investors for it to happen.
  • The day before pre-production, an investor backs out. Miller announces on his blog that the movie is seemingly dead for now.
  • A band of fans got together and decided that this wasn’t going to stop this movie from happening.  We’d heard about it, read about it, and now we were going to save it. The Blue Like Jazz Kickstarter was born.
  • Ten days later the Kickstarter campaign passes its $125k minimum to fund the movie. We did it.  Blue Like Jazz was to be the first major release American movie to be crowd sourced, and I, along with quite a few others, was now an “Executive Producer”. The campaign continued to raise money the next 20 days which helped afford better production. Taylor and Miller were stunned at how quickly this happened and got back to work on it immediately.
  • The movie was finally released in April 2012, and I rather enjoyed it.

It was an amazing experience watching something we cared about come back to life after it had been declared dead.  I couple things I learned from this adventure:

  1. If you care about something enough, try to make it happen! A few of us got over 3,000 people to join in and raise $125k.
  2. Institutions, precepts, and ‘The Man’ don’t have to be accepted blindly. If people want to see something change, they should, and can, step up and change it themselves. There’s a reason labor unions are effective at what they do.
  3. I find honest discussions about Christianity get taken much more seriously in our culture than bible thumping or Christian fantasy movies like Fireproof.

Two More of My Favorite Christmas Songs

Since I had two posts about Christmas music, I felt I needed to close it out with a third and final one.  I have two songs this time!  This first song finishes the loose narrative my last two posts kinda-sorta-connected together on: 1) Israel(and us) craves for Emmanuel to come, 2) Emmanuel did come, and 3) because of this, everything has changed.

In Like A Lion(Always Winter) is also by Relient K and is about Narnia’s ill weather.  I think that it was supposed to be on the Lion, the Witch, and the Wardrobe movie soundtrack.  If it wasn’t then I really think it should have been…

[youtube=http://www.youtube.com/watch?v=ksDBJIpqV1k&w=420&h=315]

Personally, I love winter.  I love the colder weather.  I enjoy the rain(for the most part) or snow when visiting the mountains.  I enjoy Pumpkin Spice Lattes.  I really enjoy bundling up and reading a book by the fire or window during the rain.  But, like most things, usually near the end of it am ready for winter to end and spring to show through.  Narnia(prior to Lucy Pevensie stumbling through the wardrobe) has been suffering a one hundred year long winter but never Christmas.  Some of the animals living in Narnia did not know what spring or a Christmas was.  It was a foreign concept to them.  Something wasn’t right.  Note that winter is not bad or evil.  Winter is just one part of the cycle that comes then goes and is just as important as summer, but something had abused winter’s purpose.

And then Aslan returns and sets the world right.  The green grass returns, the leaves begin to grow, Narnia is returning to as it should be.  As it was intended to be.

That is what Jesus’ mission was, to facilitate the restoration of His creation.  Throughout His life we were shown what this meant.  What truly living as God’s creation looks like.  Christmas is such an important event because of what happened afterwards.  If nothing happened after Christmas, if nothing changed, or if Aslan returned but the witch and her winter continued, there is no reason to celebrate.  With Jesus’ death we were allowed passage back to connect with God, this was the answer to Israel’s cries of O Come O Come Emmanuel.

 

I’m sorry if you’re tired of Relient K(not sorry), but they wrote a really good Christmas album.  This last song is entitled Merry Christmas, Here’s To Many More.  I’m not going to write too much about this one, I think the lyrics and pretty straight forward.

[youtube=http://www.youtube.com/watch?v=IE0s2cGVF10&w=420&h=315]

This last year hasn’t been the easiest for me.  A lot of changes, some ups, more downs, even more plateaus, and a whole lot of lets-just-get-through-this-Kevin.  When I sing I made it through the year and I did not even collapse, gotta say ‘Thank God for that’, I really mean it.  So here I am at Christmas, I made it!  Every year I think we all look back and think if we handled that we can handle anything, but it really sticks with you after a rough one.  I know I could not have gotten through this year without God shining through such great friends or family in my life(if you’re reading this then you probably fall under one of these).  He has provided me safe thoughts when I was alone, brilliant friends to hangout with, and a family to take care of me.  And He has promised me that He won’t leave.

So, from me to you, Merry Christmas and here’s to many more.

My Favorite Not-so-classic Christmas Song

I’m not 100% sure on the difference between Classic and NonClassic Christmas songs, but I know that O Come O Come Emmanuel is a Classic and I Celebrate The Day is not.  Nevertheless, it is one of my favorite Christmas songs.

Not much to stay about this song upfront, it is by Relient K and it is essentially a stream of thoughts concerning the first Christmas.

[youtube=http://www.youtube.com/watch?v=JsPFNY4Z5t0&w=420&h=315]

The song isn’t very deep, but I think it gets two things across;

  1. Many of the things that happened that first Christmas are a giant mystery.  I also wonder sometimes when Jesus knew of the gravity of what his birth meant.  Was it something He found out as He grew up?  Was something intrinsically within Him?  Or did He have a fully developed mine capable of understanding it all the moment His eyes opened?  I don’t know, these are things that seem like they can’t make any sense when something is fully God and man.  But what really matters is that Jesus was born.  And that is big news.  So big it changed this world forever.
  2. This is the reason we celebrate Christmas.  We celebrate the day that Jesus was born because it was the start of something.  It was the start of what Israel was begging for back in Assyria.

Emmanuel had come.  He had finally come!  And with Him here, since He had come as it was promised, we know what comes next.  Jesus’ birth was the beginning of our salvation.  Easter is where it all goes down, but Christmas is where it all started.  So I celebrate that day.

My Favorite Classic Christmas Song

It is that time of year again, Christmas music time!  I’m quite particular about listening to Christmas music throughout the year.  Every now and then I’ll listen to a Christmas song if it comes up on iTunes, but the closer it gets to December the more likely I am to skip it because it isn’t time yet.  As we all know, the correct time it is acceptable for Christmas music to start playing is anytime after Thanksgiving, and I always hold out until then.  I usually listen throughout December, past Christmas, and on till about the 7th of January.  There isn’t really another season with its own theme music(the recent attempt at a thanksgiving song doesn’t count), and all of the songs just make this time of year that little bit more special.

My favorite classic Christmas song is one by the name of O Come O Come Emmanuel.  A brief history: the song is translated from an older Ecclesiastical Latin text called Veni, veni, Emmanuel, written sometime between the 8th and 12th century, which was based upon the prophecy in Isaiah 7:14.

14Therefore the Lord himself will give you a sign. Look, the young woman is with child and shall bear a son, and shall name him Immanuel(meaning God with us).

At this time, the nation of Israel was currently held captive by Assyria(I think) wondering how they could have come to this.  God’s chosen people had been beaten and overtaken.  This is not how it was supposed to be.  How will Israel escape its current setting and how can it possible get better?  It really is a depressing time, which I think sets the mood for the song.

[youtube http://www.youtube.com/watch?v=Docmt1_MZVo?rel=0]

Its fairly short, the lyrics follow a very simple and similar structure, its a bit repetitive at times, but it is a song full of longing.

Israel knows of the existence of what they yearn for, but He is nowhere to be found.  They, and we, are in an agony that currently nothing on earth can satisfy.  Every verse is literally the begging for something greater to come and end their suffering; free us from being enslaved, lead us to the age to come, come back to us Lord.  The song never arrives to the time when Emmanuel does come.  Israel doesn’t get saved before the music ends.  Instead the verses all end with the hope that God will be with us someday and we are to rejoice in that.

Perhaps that is why I like it, because at its core it isn’t necessarily a Christmas song.  It is a song about us in the present day, still struggling in the same places as Israel way back in the Old Testament.

Today we are awaiting the very same Jesus to come and redeem us.

Spring Portlet Handler Mapping Error

Another post about Spring Portlet MVC.  Currently in Spring 3.1.2(and 3.1.1 as far as I can tell) there is a problem with portlet annotation handler mapping apparently due to a flaw in predicate comparison; its documented more in depth in their jira at SPR-9303.  The issue has been reported to have been fixed for Spring 3.1.3, but until that comes out I had to find a work around.

The hard part about diagnosing this bug is that it may or may not affect your portlet depending on how many annotation handlers you have, how they are structured, and in what order they are picked up by Spring.  Many of the portlets we have created haven’t had any problems(or none that we have experienced so far), but one portlet in particular was mapping every single render request to its default mapping.  Someone on stackoverflow has investigated the ordering further and shows exactly why the ordering matters.  Long story short, if the default handler mapping isn’t ordered last then any handler mappings behind it will never get used.

A workaround is simple enough, albeit a little ugly.  Remove the default annotation handler mapping method into its own class and package and have Spring component-scan to register it separately.  Like so:

<context:component-scan base-package=”com.kwilkins.portlets.foo”>
<context:exclude-filter type=”regex” expression=”com.kwilkins.portal.foo.controller.springbug..*”/>
</context:component-scan>
<!– This package temporarily exists due to spring bug; SPR-9303 –>
<context:component-scan base-package=”com.kwilkins.portlets.foo.controller.springbug”/>

Doing this should scan and register the default mapping after everything else already has been.

How Should We Deal With Loud and Hurtful People?

Has Christianity effectively been ruined for others by Christians not following many of Christ’s teachings them(our)selves but brutally attacking others for doing the same?  I understand that there are many Christians who don’t do this, and that’s great.  But I think the problem is that the Christians that do purposely seek attention while doing it(in their mind they think it is a good thing…I guess).  Should we be seeking attention and disown these actions in response?

I feel like our actions/speech should be much harsher for Christians doing that rather than for some random person breaking Christ’s example they might not even adhere to.

Spring Portlet Validation Errors

I am currently in the process of updating some of our portlets to use Spring 3.1 and the new Portlet 2.0 spec in preparation with a portal framework upgrade taking place for ZotPortal this summer.  A problem we were experiencing using the new Spring 3.0 annotations for our portlets was the new way Spring handles validation/binding errors for forms.  Before, the validation is done in the action phase, then the error(s) are stored in the model attribute, and if errors are present you can redirect back to the render phase so the initial page form will be displayed again with the submitted data but this time displayed with error messages that explain to the user why it failed validation.  I was surprised when the validation would fail this time and redirect back to the page form but no errors would show.  Apparently something changed in the way Spring handles objects placed into the model via the @ModelAttribute annotation.  Now Spring would replace an object even if it is associated with errors and they will not be present/displayed when redirected back to the form.

A few solutions have been proposed across the spring forms, stackoverflow, and the interwebs;

  1. Validate the form object during the render phase as well.  This will generate the errors and have them displayed on the form when the rendering completes.
  2. Explicitly preserve the form object or errors after the redirect and ensure they get passed to the form when rendering completes.
  3. Instead of using @ModelAttribute, persist the form object as a session attribute so it persists across the action and render phases.

Option 1 isn’t really an option for our applications.  In the initial render phases the form object would not pass our validation tests because it isn’t filled out yet!  We don’t want to display validation error messages to the user upon the first load of the form when they haven’t had a chance to submit any data yet, it would seem a bit rude in my opinion.  Validation should occur if data has been submitted.  Option 3 seemed to be overkill, submitting a simple form shouldn’t need to persist the form object in the session which lives well past the action phase of the submit.  I believe Spring has some nice ways of handling these session attributes, but I haven’t played with it very much.

I decided to use option 2.  When the render phase is deciding what object to populate the form with it first checks to see if an applicable object with errors already exists in the model, if it does it lets that object stay in the model to populate the form.  The previous submitted data and errors get passed through the render phase and displayed on the form for the user to see and fix so it can be validated properly.

I wrote an example for persisting the object and it seems the same result can be accomplished by persisting the errors object instead, but I haven’t tested that.  Options 1 and 3 can also be found in this thread.

Love is for Others

A while ago someone married to a paraplegic for 16 years was doing an AskMeAnything on reddit and got asked the question “How’s the sex life?” No doubt the person who asked was trying to be humorous, but the man gave an answer anyway.

Somehow I knew this was going to be the first question…I’m not gonna lie. Sex is one of the big issues. I wish I was a better man, and could simply ignore that side of myself, but I’m not. I get as frustrated as anyone else, and working through that is difficult.

What followed was one of the best interactions I have seen concerning the difference of what real love is and what many people think of it is, someone else followed up and pressed the issue further;

Have you ever considered or had a discussion with your wife about making the physical aspect of your relationship open? You both have needs, and I respect your patience and efforts to be a good husband. However, I feel that on a level of need you may benefit from having an agreement with your wife about a sexually open relationship while maintaining an otherwise monogamous one.

This suggestion hurts my soul every time I read it. I do not know if this person genuinely believed this idea was a good one or he was just wondering out loud what the man thought about it. What it really says, is “love should be about you getting everything you want and if you are missing anything then you should go get it elsewhere.” Sure, redefine the way a relationship works to fulfill your needs. You deserve it. You’re entitled to it.

The married man answered;

I’ve had others ask this question before, but lets be serious here.

My wife already deals with feelings of inadequacy because of the things she can’t provide for me physically. She knows I love her anyway, but she can’t help feeling like she’s somehow less than a “real” wife.

Were I to go elsewhere for sex, romping around with some able-bodied lady, even if it was done with her knowledge and nominal permission, any sense of security that she has in me, in us, would be gone. That kind of damage is irreparable.

An “open relationship” would signify only that my physical needs are more important than her emotional ones. And that just isn’t true.

Beautiful.

Yes I know, sex is not love. I think that love is greater than sex, but they are connected in ways and I think that is another way of looking at what is being misrepresented here. When this man opens himself to questions about his marriage and someone asks him about sex, he doesn’t try to disconnect the two like the second questioner does because the married man knows they are intertwined. He knows asking him “How’s the sex life?” is in part asking him “How’s the marriage life?”. I doubt his answer would probably be any different if the question was changed. The man understands that to go outside of his marriage for sex, or for anything, would render his marriage pointless. Whatever benefits he would receive from outside his marriage are worth nothing to him if his marriage or wife suffers.

I believe that our biggest need is love, but love is a funny thing because in order to do it correctly one must put another’s needs before their own. That is so hard to do sometimes. Being a selfish 22-year-old, my innate desire is not to put another’s wants or needs before my own. My brain says that the most efficient way to enjoy the benefits of life is to have all my needs met without doing any work. But because I love her, I make any of her needs more important than all of mine.  Well, I try to.  I fail a lot, but that is another story.  The point is we cannot fulfill our own need for love, we must love something beyond ourselves if we want it to be real.

One last person made a snide comment;

So it’s essentially a one-way deal, where she gets here psychological needs met, and you don’t. Got it. But then, I guess you made that decision when you got married. Oh well.

The man responded;

Not really, no. It is called love. It is letting the needs of someone else supersced your own. I’m rather sorry you feel the way you do. You’re missing out in the long run.

Easter 2012

For this year’s Easter post I’ll leave you with a quotation from a recent book I read.

The point of the resurrection…is that the present bodily life is not valueless just because it will die…What you do with your body in the present matters because God has a great future in store for it…What you do in the present—by painting, preaching, singing, sewing, praying, teaching, building hospitals, digging wells, campaigning for justice, writing poems, caring for the needy, loving your neighbor as yourself—will last into God’s future. These activities are not simply ways of making the present life a little less beastly, a little more bearable, until the day when we leave it behind altogether (as the hymn so mistakenly puts it…). They are part of what we may call building for God’s kingdom.

― N.T. WrightSurprised by Hope: Rethinking Heaven, the Resurrection, and the Mission of the Church

My previous Easter posts if you’re interested.