You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Oleg V Alexeev <go...@penza.net> on 2001/02/14 07:04:19 UTC

Re[2]: As promised (Struts Presentation)

Hello Maya,

Wednesday, February 14, 2001, 2:56:18 AM, you wrote:

MM> 1/ Is it possible to change a language on-line. For example one user uses English
MM> language with his browser, then he switchs to French. Can Struts handle this? I
MM> think, in your document the properties file is loaded in the beginning
MM> ActionServlet startup.

JVM load all files in properties bundle at once and all this
resources can be used in run time. Example of switching to another
locale -

public class ChangeLanguageAction extends Action {

    public ActionForward perform(
            ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response)
            throws IOException, ServletException {
        String country = ((ChangeLanguageForm) form).getCountry();
        String language = ((ChangeLanguageForm) form).getLanguage();
        String source = ((ChangeLanguageForm) form).getSource();
        HttpSession session = request.getSession();
        ActionForward forward = null;

        setLocale( request, new Locale( language, country ) );

        if( source==null )
         forward = (mapping.findForward("success"));
        else {
         forward = new RedirectingActionForward();
         forward.setPath( source );
        }

        return forward;
    }

}

MM> 2/ How replace images with a text through properties file? (I think this question
MM> was posted already).

  You can store image file names in properties in use it in <img> tags
  - <img src='<bean:message key="picture.cat.english"/>'>
  <img src='<bean:message key="picture.cat.french"/>'>
  
  May be I not understand your 2/ question... Explane please, if so.

-- 
Best regards,
 Oleg                            mailto:gonza@penza.net



Re[2]: As promised (Struts Presentation)

Posted by Oleg V Alexeev <go...@penza.net>.
Hello Maya,

Wednesday, February 14, 2001, 3:12:04 PM, you wrote:

MM> Oleg,
MM> Thank you very much for very detail, helpful answer.
MM> The best wishes and good luck.
MM> Maya

Always welcome. 8)

>>   You can store image file names in properties in use it in <img> tags
>>   - <img src='<bean:message key="picture.cat.english"/>'>
>>   <img src='<bean:message key="picture.cat.french"/>'>
>>

Recently I fix <html:img> tag and post it to the struts-dev. If Craig
apply it then you can avoid such constructions as -
 <img src='<bean:message key="picture.cat.french"/>'>
and use <html:img> tag -
 <html:img path="images" srckey="picture.cat.english" altkey="Cat!"/>

-- 
Best regards,
 Oleg                            mailto:gonza@penza.net



File UpLoad

Posted by Byomakesh Parida <bp...@teomedia.com>.
Hi,
 i am facing the problem when i used to upload the files. when i am passing
the parameter to the form (enctype="multipart/form-data", it gives the error
like

500 Internal Server Error
/mediaman/saveIconFileUpLoadAction.do:

javax.servlet.ServletException: BeanUtils.populate
java.lang.IllegalArgumentException: argument type mismatch
	at java.lang.reflect.Method.invoke(Native Method)
	at
org.apache.struts.util.PropertyUtils.setSimpleProperty(PropertyUtils.java:82
4)
	at
org.apache.struts.util.PropertyUtils.setNestedProperty(PropertyUtils.java:75
5)
	at org.apache.struts.util.PropertyUtils.setProperty(PropertyUtils.java:781)
	at org.apache.struts.util.BeanUtils.populate(BeanUtils.java:563)
	at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:333)
	at
org.apache.struts.action.ActionServlet.processPopulate(ActionServlet.java:18
05)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1416)
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:481)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
	at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1013)
	at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:925)
	at
allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.jav
a:88)
	at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1131)
	at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java:330)
	at allaire.jrun.jrpp.ProxyEndpoint.run(ProxyEndpoint.java:354)
	at allaire.jrun.ThreadPool.run(ThreadPool.java:267)
	at allaire.jrun.WorkerThread.run(WorkerThread.java:74)

where as i hava used the populate method properly.
can anybody help me in this case.

cheers
Byomakesh



Re: As promised (Struts Presentation)

Posted by Maya Muchnik <mm...@pumatech.com>.
Oleg,
Thank you very much for very detail, helpful answer.
The best wishes and good luck.
Maya

Oleg V Alexeev wrote:

> Hello Maya,
>
> Wednesday, February 14, 2001, 2:56:18 AM, you wrote:
>
> MM> 1/ Is it possible to change a language on-line. For example one user uses English
> MM> language with his browser, then he switchs to French. Can Struts handle this? I
> MM> think, in your document the properties file is loaded in the beginning
> MM> ActionServlet startup.
>
> JVM load all files in properties bundle at once and all this
> resources can be used in run time. Example of switching to another
> locale -
>
> public class ChangeLanguageAction extends Action {
>
>     public ActionForward perform(
>             ActionMapping mapping,
>             ActionForm form,
>             HttpServletRequest request,
>             HttpServletResponse response)
>             throws IOException, ServletException {
>         String country = ((ChangeLanguageForm) form).getCountry();
>         String language = ((ChangeLanguageForm) form).getLanguage();
>         String source = ((ChangeLanguageForm) form).getSource();
>         HttpSession session = request.getSession();
>         ActionForward forward = null;
>
>         setLocale( request, new Locale( language, country ) );
>
>         if( source==null )
>          forward = (mapping.findForward("success"));
>         else {
>          forward = new RedirectingActionForward();
>          forward.setPath( source );
>         }
>
>         return forward;
>     }
>
> }
>
> MM> 2/ How replace images with a text through properties file? (I think this question
> MM> was posted already).
>
>   You can store image file names in properties in use it in <img> tags
>   - <img src='<bean:message key="picture.cat.english"/>'>
>   <img src='<bean:message key="picture.cat.french"/>'>
>
>   May be I not understand your 2/ question... Explane please, if so.
>
> --
> Best regards,
>  Oleg                            mailto:gonza@penza.net


Re: Question on html:link

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Alan Yackel wrote:

> I'm trying write a page with a link back to the referring page.  I can get the page from
> <bean:header>, but how would I put a link to this?  I don't see a way to do this.  I'm
> thinking that I need to either write a new tag or an action to do handle this.  Or go
> ahead and put java code in the .jsp, which I want to avoid.
>
> Thanks for any help,
> Alan Yackel

One approach would be a runtime expression:

    <bean:header id="referer" name="Referer"/>
    <html:link href="<%= referer %>" .../>

which works because the <bean:header> tag creates a scripting variable along with a page
context attribute, in the same way that <jsp:useBean> does.

Otherwise, we would need to enhance the link tag to accept its href from a bean (which is
not a bad idea), and/or you could write a custom tag of your own.

Craig



Question on html:link

Posted by Alan Yackel <ay...@home.com>.
I'm trying write a page with a link back to the referring page.  I can get the page from
<bean:header>, but how would I put a link to this?  I don't see a way to do this.  I'm
thinking that I need to either write a new tag or an action to do handle this.  Or go
ahead and put java code in the .jsp, which I want to avoid.

Thanks for any help,
Alan Yackel