You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by PEGASUS84 <pe...@hotmail.it> on 2009/04/08 00:36:37 UTC

create personal interceptor

I want create an interceptors wich converts the list of select tag mese in
another string:1,2...
i make this:  


package bean;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.opensymphony.xwork2.Action;
public class convMese implements Interceptor{
    String mese;

    
    public void setMese(String m){mese=m;}
    public String getMese(){return mese;}



public void destroy() {
}
public void init() {
}
public String intercept( ActionInvocation actionInvocation) throws
Exception{
    if (getMese().equals("Gennaio"))
        setMese("1");
    else if(getMese().equals("Febbraio"))
        setMese("2");
    else if(getMese().equals("Marzo"))
        setMese("3");
    else if(getMese().equals("Aprile"))
        setMese("4");
    else if(getMese().equals("Maggio"))
        setMese("5");
    else if(getMese().equals("Giugno"))
        setMese("6");
    else if(getMese().equals("Luglio"))
        setMese("7");
    else if(getMese().equals("Settembre"))
        setMese("9");
    else if(getMese().equals("Ottobre"))
        setMese("10");
    else if(getMese().equals("Novembre"))
        setMese("11");
    else if(getMese().equals("Dicembre"))
        setMese("12");
    else
        setMese("0");

 
      return actionInvocation.invoke();

}

but it doesn't work
can someone help me?
-- 
View this message in context: http://www.nabble.com/create-personal-interceptor-tp22939722p22939722.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


RE: create personal interceptor

Posted by Martin Gainty <mg...@hotmail.com>.
you dont need an interceptor as you wont be modifying request params 

sub in date value when you declare it in Action class

java class

public class SomeAction extends DefaultActionSupport {
{
 private Date date=new Date("2006-06-26");
 public void getDate() { return date ; }
 public setDate(Date date) { this.date=date; }
     public String displayResult() {
        return "SUCCESS";
    }
}
}
then in the index.jsp reference the date in value= as in here
<sx:datetimepicker label="IT format with initial date of 2006-06-26 and long formatting (parse not supported)" name="dddp12" value="%{date}" formatLength="long" language="it-it" />
HTH
Martin 

If I have any beliefs about immortality, it is that certain dogs I have known will go to heaven, and very, very few persons. - J.T.
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.






> Date: Tue, 7 Apr 2009 18:49:32 -0400
> From: Terry.Gardner@Sun.COM
> Subject: Re: create personal interceptor
> To: user@struts.apache.org
> 
> I think you can use date formatters in java.text to accomplish this  
> with no coding.
> 
> On Apr 7, 2009, at 6:36 PM, PEGASUS84 wrote:
> 
> >
> > I want create an interceptors wich converts the list of select tag  
> > mese in
> > another string:1,2...
> > i make this:
> >
> >
> > package bean;
> > import com.opensymphony.xwork2.ActionInvocation;
> > import com.opensymphony.xwork2.interceptor.Interceptor;
> > import com.opensymphony.xwork2.Action;
> > public class convMese implements Interceptor{
> >    String mese;
> >
> >
> >    public void setMese(String m){mese=m;}
> >    public String getMese(){return mese;}
> >
> >
> >
> > public void destroy() {
> > }
> > public void init() {
> > }
> > public String intercept( ActionInvocation actionInvocation) throws
> > Exception{
> >    if (getMese().equals("Gennaio"))
> >        setMese("1");
> >    else if(getMese().equals("Febbraio"))
> >        setMese("2");
> >    else if(getMese().equals("Marzo"))
> >        setMese("3");
> >    else if(getMese().equals("Aprile"))
> >        setMese("4");
> >    else if(getMese().equals("Maggio"))
> >        setMese("5");
> >    else if(getMese().equals("Giugno"))
> >        setMese("6");
> >    else if(getMese().equals("Luglio"))
> >        setMese("7");
> >    else if(getMese().equals("Settembre"))
> >        setMese("9");
> >    else if(getMese().equals("Ottobre"))
> >        setMese("10");
> >    else if(getMese().equals("Novembre"))
> >        setMese("11");
> >    else if(getMese().equals("Dicembre"))
> >        setMese("12");
> >    else
> >        setMese("0");
> >
> >
> >      return actionInvocation.invoke();
> >
> > }
> >
> > but it doesn't work
> > can someone help me?
> > -- 
> > View this message in context: http://www.nabble.com/create-personal-interceptor-tp22939722p22939722.html
> > Sent from the Struts - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> 
> ==
> 
> Terry.Gardner@Sun.COM
> Mobile: +1 404 925 6385
> Blog: http://blogs.sun.com/terrygardner
> Blog: http://dtfar.blogspot.com
> Twitter: http://twitter.com/tgardner
> SLAMD: http://slamd2.dev.java.net
> 
> "It is better to know some of the questions than all of the answers."  
> - Thurber
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Rediscover Hotmail®: Now available on your iPhone or BlackBerry
http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Mobile1_042009

RE: create personal interceptor

Posted by Martin Gainty <mg...@hotmail.com>.
ask the question what is the reason why you must use <personal> interceptor
1)are you extracting and or modifying the request?
2)Is there some function you must perform before or after Action is executed
that the action itself cannot handle?

Please read:
http://struts.apache.org/2.x/docs/interceptors.html#Interceptors-UnderstandingInterceptors

If you can state why you need an interceptor then I et al will help you code one

Bon Chance/Vielen Danke
Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.






> Date: Wed, 8 Apr 2009 02:52:33 -0700
> From: pegasus84@hotmail.it
> To: user@struts.apache.org
> Subject: Re: create personal interceptor
> 
> 
> ok but i must use personal interceptor for my project
> 
> 
> Terry Gardner-2 wrote:
> > 
> > I think you can use date formatters in java.text to accomplish this  
> > with no coding.
> > 
> > On Apr 7, 2009, at 6:36 PM, PEGASUS84 wrote:
> > 
> >>
> >> I want create an interceptors wich converts the list of select tag  
> >> mese in
> >> another string:1,2...
> >> i make this:
> >>
> >>
> >> package bean;
> >> import com.opensymphony.xwork2.ActionInvocation;
> >> import com.opensymphony.xwork2.interceptor.Interceptor;
> >> import com.opensymphony.xwork2.Action;
> >> public class convMese implements Interceptor{
> >>    String mese;
> >>
> >>
> >>    public void setMese(String m){mese=m;}
> >>    public String getMese(){return mese;}
> >>
> >>
> >>
> >> public void destroy() {
> >> }
> >> public void init() {
> >> }
> >> public String intercept( ActionInvocation actionInvocation) throws
> >> Exception{
> >>    if (getMese().equals("Gennaio"))
> >>        setMese("1");
> >>    else if(getMese().equals("Febbraio"))
> >>        setMese("2");
> >>    else if(getMese().equals("Marzo"))
> >>        setMese("3");
> >>    else if(getMese().equals("Aprile"))
> >>        setMese("4");
> >>    else if(getMese().equals("Maggio"))
> >>        setMese("5");
> >>    else if(getMese().equals("Giugno"))
> >>        setMese("6");
> >>    else if(getMese().equals("Luglio"))
> >>        setMese("7");
> >>    else if(getMese().equals("Settembre"))
> >>        setMese("9");
> >>    else if(getMese().equals("Ottobre"))
> >>        setMese("10");
> >>    else if(getMese().equals("Novembre"))
> >>        setMese("11");
> >>    else if(getMese().equals("Dicembre"))
> >>        setMese("12");
> >>    else
> >>        setMese("0");
> >>
> >>
> >>      return actionInvocation.invoke();
> >>
> >> }
> >>
> >> but it doesn't work
> >> can someone help me?
> >> -- 
> >> View this message in context:
> >> http://www.nabble.com/create-personal-interceptor-tp22939722p22939722.html
> >> Sent from the Struts - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> > 
> > ==
> > 
> > Terry.Gardner@Sun.COM
> > Mobile: +1 404 925 6385
> > Blog: http://blogs.sun.com/terrygardner
> > Blog: http://dtfar.blogspot.com
> > Twitter: http://twitter.com/tgardner
> > SLAMD: http://slamd2.dev.java.net
> > 
> > "It is better to know some of the questions than all of the answers."  
> > - Thurber
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/create-personal-interceptor-tp22939722p22947039.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Windows Live™: Keep your life in sync.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_042009

Re: create personal interceptor

Posted by Terry Gardner <Te...@Sun.COM>.
I see. Please be more specific about what you mean when you write that  
it does not work. The interceptor you have coded does not inject the  
"mese" into any action, but it does convert internally from month  
names to numbers.

Perhaps you could create an interface called "MeseAware":

public interface MeseAware
{
	public void setMeseAsNumberString(String meseAsNumberString);
}

and implement it in your action that needs mese as a number. Then  
inject it from your interceptor:

	...
	Action action = (Action)actionInvocation().getAction();
	if(action instanceof MeseAware)
	{
		((MeseAware)action).setMeseAsNumberString(getMese());
	}

Other things:

- Since you do not need the init() and destroy() methods, you might  
consider extending AbstractInterceptor instead of implementing  
Interceptor.
- Java classes names should begin with upper-case letters, like  
"public class ConvMese".
- Java "ifs" should have braces, even if they are only one-liners

On Apr 8, 2009, at 5:52 AM, PEGASUS84 wrote:

>
> ok but i must use personal interceptor for my project
>
>
> Terry Gardner-2 wrote:
>>
>> I think you can use date formatters in java.text to accomplish this
>> with no coding.
>>
>> On Apr 7, 2009, at 6:36 PM, PEGASUS84 wrote:
>>
>>>
>>> I want create an interceptors wich converts the list of select tag
>>> mese in
>>> another string:1,2...
>>> i make this:
>>>
>>>
>>> package bean;
>>> import com.opensymphony.xwork2.ActionInvocation;
>>> import com.opensymphony.xwork2.interceptor.Interceptor;
>>> import com.opensymphony.xwork2.Action;
>>> public class convMese implements Interceptor{
>>>   String mese;
>>>
>>>
>>>   public void setMese(String m){mese=m;}
>>>   public String getMese(){return mese;}
>>>
>>>
>>>
>>> public void destroy() {
>>> }
>>> public void init() {
>>> }
>>> public String intercept( ActionInvocation actionInvocation) throws
>>> Exception{
>>>   if (getMese().equals("Gennaio"))
>>>       setMese("1");
>>>   else if(getMese().equals("Febbraio"))
>>>       setMese("2");
>>>   else if(getMese().equals("Marzo"))
>>>       setMese("3");
>>>   else if(getMese().equals("Aprile"))
>>>       setMese("4");
>>>   else if(getMese().equals("Maggio"))
>>>       setMese("5");
>>>   else if(getMese().equals("Giugno"))
>>>       setMese("6");
>>>   else if(getMese().equals("Luglio"))
>>>       setMese("7");
>>>   else if(getMese().equals("Settembre"))
>>>       setMese("9");
>>>   else if(getMese().equals("Ottobre"))
>>>       setMese("10");
>>>   else if(getMese().equals("Novembre"))
>>>       setMese("11");
>>>   else if(getMese().equals("Dicembre"))
>>>       setMese("12");
>>>   else
>>>       setMese("0");
>>>
>>>
>>>     return actionInvocation.invoke();
>>>
>>> }
>>>
>>> but it doesn't work
>>> can someone help me?
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/create-personal-interceptor-tp22939722p22939722.html
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>
>> ==
>>
>> Terry.Gardner@Sun.COM
>> Mobile: +1 404 925 6385
>> Blog: http://blogs.sun.com/terrygardner
>> Blog: http://dtfar.blogspot.com
>> Twitter: http://twitter.com/tgardner
>> SLAMD: http://slamd2.dev.java.net
>>
>> "It is better to know some of the questions than all of the answers."
>> - Thurber
>>
>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/create-personal-interceptor-tp22939722p22947039.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


======

Terry Gardner
Terry.Gardner@Sun.COM

"Vulcans never bluff." -- Spock


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


Re: create personal interceptor

Posted by PEGASUS84 <pe...@hotmail.it>.
ok but i must use personal interceptor for my project


Terry Gardner-2 wrote:
> 
> I think you can use date formatters in java.text to accomplish this  
> with no coding.
> 
> On Apr 7, 2009, at 6:36 PM, PEGASUS84 wrote:
> 
>>
>> I want create an interceptors wich converts the list of select tag  
>> mese in
>> another string:1,2...
>> i make this:
>>
>>
>> package bean;
>> import com.opensymphony.xwork2.ActionInvocation;
>> import com.opensymphony.xwork2.interceptor.Interceptor;
>> import com.opensymphony.xwork2.Action;
>> public class convMese implements Interceptor{
>>    String mese;
>>
>>
>>    public void setMese(String m){mese=m;}
>>    public String getMese(){return mese;}
>>
>>
>>
>> public void destroy() {
>> }
>> public void init() {
>> }
>> public String intercept( ActionInvocation actionInvocation) throws
>> Exception{
>>    if (getMese().equals("Gennaio"))
>>        setMese("1");
>>    else if(getMese().equals("Febbraio"))
>>        setMese("2");
>>    else if(getMese().equals("Marzo"))
>>        setMese("3");
>>    else if(getMese().equals("Aprile"))
>>        setMese("4");
>>    else if(getMese().equals("Maggio"))
>>        setMese("5");
>>    else if(getMese().equals("Giugno"))
>>        setMese("6");
>>    else if(getMese().equals("Luglio"))
>>        setMese("7");
>>    else if(getMese().equals("Settembre"))
>>        setMese("9");
>>    else if(getMese().equals("Ottobre"))
>>        setMese("10");
>>    else if(getMese().equals("Novembre"))
>>        setMese("11");
>>    else if(getMese().equals("Dicembre"))
>>        setMese("12");
>>    else
>>        setMese("0");
>>
>>
>>      return actionInvocation.invoke();
>>
>> }
>>
>> but it doesn't work
>> can someone help me?
>> -- 
>> View this message in context:
>> http://www.nabble.com/create-personal-interceptor-tp22939722p22939722.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
> 
> ==
> 
> Terry.Gardner@Sun.COM
> Mobile: +1 404 925 6385
> Blog: http://blogs.sun.com/terrygardner
> Blog: http://dtfar.blogspot.com
> Twitter: http://twitter.com/tgardner
> SLAMD: http://slamd2.dev.java.net
> 
> "It is better to know some of the questions than all of the answers."  
> - Thurber
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/create-personal-interceptor-tp22939722p22947039.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: create personal interceptor

Posted by Terry Gardner <Te...@Sun.COM>.
I think you can use date formatters in java.text to accomplish this  
with no coding.

On Apr 7, 2009, at 6:36 PM, PEGASUS84 wrote:

>
> I want create an interceptors wich converts the list of select tag  
> mese in
> another string:1,2...
> i make this:
>
>
> package bean;
> import com.opensymphony.xwork2.ActionInvocation;
> import com.opensymphony.xwork2.interceptor.Interceptor;
> import com.opensymphony.xwork2.Action;
> public class convMese implements Interceptor{
>    String mese;
>
>
>    public void setMese(String m){mese=m;}
>    public String getMese(){return mese;}
>
>
>
> public void destroy() {
> }
> public void init() {
> }
> public String intercept( ActionInvocation actionInvocation) throws
> Exception{
>    if (getMese().equals("Gennaio"))
>        setMese("1");
>    else if(getMese().equals("Febbraio"))
>        setMese("2");
>    else if(getMese().equals("Marzo"))
>        setMese("3");
>    else if(getMese().equals("Aprile"))
>        setMese("4");
>    else if(getMese().equals("Maggio"))
>        setMese("5");
>    else if(getMese().equals("Giugno"))
>        setMese("6");
>    else if(getMese().equals("Luglio"))
>        setMese("7");
>    else if(getMese().equals("Settembre"))
>        setMese("9");
>    else if(getMese().equals("Ottobre"))
>        setMese("10");
>    else if(getMese().equals("Novembre"))
>        setMese("11");
>    else if(getMese().equals("Dicembre"))
>        setMese("12");
>    else
>        setMese("0");
>
>
>      return actionInvocation.invoke();
>
> }
>
> but it doesn't work
> can someone help me?
> -- 
> View this message in context: http://www.nabble.com/create-personal-interceptor-tp22939722p22939722.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

==

Terry.Gardner@Sun.COM
Mobile: +1 404 925 6385
Blog: http://blogs.sun.com/terrygardner
Blog: http://dtfar.blogspot.com
Twitter: http://twitter.com/tgardner
SLAMD: http://slamd2.dev.java.net

"It is better to know some of the questions than all of the answers."  
- Thurber







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