You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de> on 2009/02/05 21:12:09 UTC

Xwork Question - how to Inject another instance than default

Hi.
I did some rework to the struts2-portlet2-plugin to make it possible to hook 
in a custom URLBuilder.

I declared a default one like this:

<bean type="org.apache.struts2.portlet.util.PortletURLBuilder" name="default" 
class="Default" />

My application e.g. wants to support liferay using a custom url builder.

Using

<bean type="org.apache.struts2.portlet.util.PortletURLBuilder" name="default" 
class=Custom />

does not work because "default" is already loaded. 
How can i tell xwork, to inject my custom instance instead the default one?
What the common way to do this?

thx for help.

Torsten


Re: Xwork Question - how to Inject another instance than default

Posted by Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de>.
Am Freitag, 6. Februar 2009 06:59:30 schrieb Nils-Helge Garli Hegvik:
> I'm curious, why do you need a custom URL builder for Liferay?

To support the "custom" window states POP_UP and EXCLUSIVE liferay does 
provide.
Made the Helper a singleton instance injected into the PortletURLRenderer 
(missed the glue how to plugin my own one ... that why i am asking) and 
changed the visibility of getWindowState to protected.

So its easy to plugin in my custom implementation which does only override the 
getWindowState method ro read like this:

...
  if ("pop_up".equalsIgnoreCase(windowState)) {
                state = LiferayWindowState.POP_UP;
  } else if("exclusive".equalsIgnoreCase(windowState)) {
                state = LiferayWindowState.EXCLUSIVE;
  }
if(state == null) {
	return super.getWindowState(....);
}
...

I thought doing it this way might be a good idea. Its working fine and enables 
me to use these custom window states.
I you got some "better" idea how to implement this "enhancement" don't bother 
to tell me please.

thx

Torsten

PS: Thought this might be good at the dev list because it is about developing 
the portlet2 plugin, however i am going to post this to the user list instead 
in the future.

-- 
Bitte senden Sie mir keine Word- oder PowerPoint-Anhänge.
Siehe http://www.gnu.org/philosophy/no-word-attachments.de.html

Really, I'm not out to destroy Microsoft. That will just be a 
completely unintentional side effect."
	-- Linus Torvalds

Re: Xwork Question - how to Inject another instance than default

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
I'm curious, why do you need a custom URL builder for Liferay?

Nils-H

On Thu, Feb 5, 2009 at 9:12 PM, Torsten Krah
<tk...@fachschaft.imn.htwk-leipzig.de> wrote:
> Hi.
> I did some rework to the struts2-portlet2-plugin to make it possible to hook
> in a custom URLBuilder.
>
> I declared a default one like this:
>
> <bean type="org.apache.struts2.portlet.util.PortletURLBuilder" name="default"
> class="Default" />
>
> My application e.g. wants to support liferay using a custom url builder.
>
> Using
>
> <bean type="org.apache.struts2.portlet.util.PortletURLBuilder" name="default"
> class=Custom />
>
> does not work because "default" is already loaded.
> How can i tell xwork, to inject my custom instance instead the default one?
> What the common way to do this?
>
> thx for help.
>
> Torsten
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Xwork Question - how to Inject another instance than default

Posted by Musachy Barroso <mu...@gmail.com>.
In the future please post these questions to the user list, this list
is for the development of Struts itself.

//ooops
musachy

On Thu, Feb 5, 2009 at 3:25 PM, Musachy Barroso <mu...@gmail.com> wrote:
> You first define a bean with a different name, and then find a setting
> that is the implementation "switch" and set it your bean name, like:
>
> <bean type="org.apache.struts2.components.UrlRenderer"
> name="myurlrenderer" class="MyPortletUrlRenderer"/>
>
> <!-- this is the "switch" -->
> <constant name="struts.urlRenderer" value="myurlrenderer" />
>
> note that on the bean the "type" is the Struts interface and the
> "class" is the actual implementation.
>
> musachy
>
> On Thu, Feb 5, 2009 at 3:12 PM, Torsten Krah
> <tk...@fachschaft.imn.htwk-leipzig.de> wrote:
>> Hi.
>> I did some rework to the struts2-portlet2-plugin to make it possible to hook
>> in a custom URLBuilder.
>>
>> I declared a default one like this:
>>
>> <bean type="org.apache.struts2.portlet.util.PortletURLBuilder" name="default"
>> class="Default" />
>>
>> My application e.g. wants to support liferay using a custom url builder.
>>
>> Using
>>
>> <bean type="org.apache.struts2.portlet.util.PortletURLBuilder" name="default"
>> class=Custom />
>>
>> does not work because "default" is already loaded.
>> How can i tell xwork, to inject my custom instance instead the default one?
>> What the common way to do this?
>>
>> thx for help.
>>
>> Torsten
>>
>>
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Xwork Question - how to Inject another instance than default

Posted by Musachy Barroso <mu...@gmail.com>.
You first define a bean with a different name, and then find a setting
that is the implementation "switch" and set it your bean name, like:

<bean type="org.apache.struts2.components.UrlRenderer"
name="myurlrenderer" class="MyPortletUrlRenderer"/>

<!-- this is the "switch" -->
<constant name="struts.urlRenderer" value="myurlrenderer" />

note that on the bean the "type" is the Struts interface and the
"class" is the actual implementation.

musachy

On Thu, Feb 5, 2009 at 3:12 PM, Torsten Krah
<tk...@fachschaft.imn.htwk-leipzig.de> wrote:
> Hi.
> I did some rework to the struts2-portlet2-plugin to make it possible to hook
> in a custom URLBuilder.
>
> I declared a default one like this:
>
> <bean type="org.apache.struts2.portlet.util.PortletURLBuilder" name="default"
> class="Default" />
>
> My application e.g. wants to support liferay using a custom url builder.
>
> Using
>
> <bean type="org.apache.struts2.portlet.util.PortletURLBuilder" name="default"
> class=Custom />
>
> does not work because "default" is already loaded.
> How can i tell xwork, to inject my custom instance instead the default one?
> What the common way to do this?
>
> thx for help.
>
> Torsten
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org