You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Craig Tataryn <Cr...@msdw.com> on 2001/02/13 21:37:20 UTC

As promised (Struts Presentation)

============================
Craig M.: Can you add the link to the presentation (if you deem it
suitable) to the resources section of the Struts User Guide?
============================

URL forwarding sucks.  Given that, I will have to give you the link to
the presentation as it exists on the server space I am borrowing until I
get my own server box.  The URL may change in the future to my
computer-programmer.org domain.

The Struts presentation I did can be found (at least for the time being)
at:
    http://www.us-eh.com/craiger/articles/struts/

Let me know of any problems or suggestions you may have about the
presentation!

Thanks,

Craig.

--
I've been trying to change the world for years, but they just won't give
me the source code....


Re: Deprecated API

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

> I tried asking this on struts-dev, but got no reply.  What I'm wondering is
> why
> is the Digester built on the deprecated HandlerBase instead of the SAX2
> DefaultHandler?  Switching over to the newer SAX2 classes doesn't required
> too much
> work.  I did it with one other application.  It's mostly changing
> AttributeList to
> Attributes and changing the parameter list on a few methods.

Sorry for the no response on STRUTS-DEV ... I've been heads down on bug
fixes
getting ready for a 1.0 release.

The primary issue for Struts is to be compatible with as wide a range of
XML
parsers as possible, because different apps will have different
preferences.  To
date, there are a few SAX2 parsers, but only one compliant one that
conforms to
the JAXP APIs (see next paragraph), which is also matters.

>
> Also I'm curious why Struts doesn't use the
> org.apache.xerces.parser.SAXParser instead
> of the one in javax.xml.parsers.  I would think that apache projects would
> try leverage
> work from other apache projects.  I'm in the middle of building a software
> application
> based on Struts for an internet consulting company.  I love the features and
> flexibility
> of Struts, but it's nice to keep current with technology.

The javax.xml.parsers family of interfaces are part of the Java API for
XML
Processing (JAXP) suite, which ensures applications that they can be
independent
of the actual parser being used.  Using
org.apache.xerces.parser.SAXParser
directly would require a Struts app to use only Xerces, which is not
optimal for
every environment.

In addition, the Apache-specific APIs have been in substantial churn
over the
last few versions -- my preference will be to let this settle down (and
let
Xerces catch up to implementing the standard JAXP 1.1 interfaces) before
updating the technology that Digester uses.

>
> Just asking,
>
> Alan Yackel
> Creatrixs Inc.

Craig McClanahan

Deprecated API

Posted by Alan Yackel <ay...@home.com>.
I tried asking this on struts-dev, but got no reply.  What I'm wondering is
why
is the Digester built on the deprecated HandlerBase instead of the SAX2
DefaultHandler?  Switching over to the newer SAX2 classes doesn't required
too much
work.  I did it with one other application.  It's mostly changing
AttributeList to
Attributes and changing the parameter list on a few methods.

Also I'm curious why Struts doesn't use the
org.apache.xerces.parser.SAXParser instead
of the one in javax.xml.parsers.  I would think that apache projects would
try leverage
work from other apache projects.  I'm in the middle of building a software
application
based on Struts for an internet consulting company.  I love the features and
flexibility
of Struts, but it's nice to keep current with technology.

Just asking,

Alan Yackel
Creatrixs Inc.




Re: As promised (Struts Presentation)

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

> <drool>Arrrrrgggghhhh, Dark Angel</drool>
>
> Ted, I'll cut the "only" word out of there tonight after I watch the
> aforementioned program.  But as far as I know, ActionForm is the only Model
> type class that Struts really manages for you auto-magically.
>

That is correct.  The property utility modules will work on any JavaBean, but
automagic parameter population only works on ActionForm subclasses.

>
> Craig.
>

Craig (M)



Re: As promised (Struts Presentation)

Posted by Craig Tataryn <Cr...@msdw.com>.
Check. Updated i8n to i18n.

Thanks,

Craig.

Maya Muchnik wrote:

> Craig,
> You have an error on page 28: not i8n, but i18n. I have got the explanations on
> it.
> Maya
>
> Craig Tataryn wrote:
>
> > <drool>Arrrrrgggghhhh, Dark Angel</drool>
> >
> > Ted, I'll cut the "only" word out of there tonight after I watch the
> > aforementioned program.  But as far as I know, ActionForm is the only Model
> > type class that Struts really manages for you auto-magically.
> >
> > Craig.
> >
> > Ted Husted wrote:
> >
> > > Kewl!
> > >
> > > I think I know what I'll be doning after Dark Angel tonight!
> > >
> > > I did notice one point on page 17, where it says "Struts will only
> > > handle models in an automatic fashion if you extended
> > > org.apache.struts.action.ActionForm"
> > >
> > > Is the word "only" accurate?
> > >
> > > I believe Struts works best if the form beans are ActionForm subclasses,
> > > but I think the form and action would work just fine with any JavaBean.
> > >
> > > -Ted.
> > >
> > > Craig Tataryn wrote:
> > > >
> > > > ============================
> > > > Craig M.: Can you add the link to the presentation (if you deem it
> > > > suitable) to the resources section of the Struts User Guide?
> > > > ============================
> > > >
> > > > URL forwarding sucks.  Given that, I will have to give you the link to
> > > > the presentation as it exists on the server space I am borrowing until I
> > > > get my own server box.  The URL may change in the future to my
> > > > computer-programmer.org domain.
> > > >
> > > > The Struts presentation I did can be found (at least for the time being)
> > > > at:
> > > >     http://www.us-eh.com/craiger/articles/struts/
> > > >
> > > > Let me know of any problems or suggestions you may have about the
> > > > presentation!
> > > >
> > > > Thanks,
> > > >
> > > > Craig.
> > > >
> > > > --
> > > > I've been trying to change the world for years, but they just won't give
> > > > me the source code....
> >
> > --
> > I've been trying to change the world for years, but they just won't give me
> > the source code....

--
I've been trying to change the world for years, but they just won't give me the
source code....


Re: As promised (Struts Presentation)

Posted by Maya Muchnik <mm...@pumatech.com>.
Craig T.,

Thank you very much for your response. And I have got the answer for my
2nd Q. from Oleg.
Maya

Craig Tataryn wrote:

> Maya,
>
> 1) The language should change from the default after the user changes
> his/her browser language if:
>
>   1. the user does a refresh in his browser (or perhaps just clicks a
>      link to another part of the app)
>   2. the language they have choosen is supported by the web app
>
> When you specify the Resource file in the application init param it
> simply specifies a default Resources class.  After that, if the locale
> changes it tries to append the ISO language characters to the end of
> the class name to see if it can find a supporting Resource file.
>
> 2) Not sure I understand the second question :(
>
> Craig T.
>
> Maya Muchnik wrote:
>
>> The same error is on pages 29 - 31.
>>
>> After reading your document, I have two questions:
>>
>> 1/ Is it possible to change a language on-line. For example one user
>> uses English
>> language with his browser, then he switchs to French. Can Struts
>> handle this? I
>> think, in your document the properties file is loaded in the
>> beginning
>> ActionServlet startup.
>>
>> 2/ How replace images with a text through properties file? (I think
>> this question
>> was posted already).
>>
>> Maya
>>
>> Maya Muchnik wrote:
>>
>> > Craig,
>> > You have an error on page 28: not i8n, but i18n. I have got the
>> explanations on
>> > it.
>> > Maya
>> >
>> >
>> > > > >
>> > > > > The Struts presentation I did can be found (at least for the
>> time being)
>> > > > > at:
>> > > > >     http://www.us-eh.com/craiger/articles/struts/
>> > > > >
>
> --
> I've been trying to change the world for years, but they just won't
> give me the source code....
>

Re: As promised (Struts Presentation)

Posted by Craig Tataryn <Cr...@msdw.com>.
Maya,

1) The language should change from the default after the user changes his/her browser
language if:

  1. the user does a refresh in his browser (or perhaps just clicks a link to another
     part of the app)
  2. the language they have choosen is supported by the web app

When you specify the Resource file in the application init param it simply specifies
a default Resources class.  After that, if the locale changes it tries to append the
ISO language characters to the end of the class name to see if it can find a
supporting Resource file.

2) Not sure I understand the second question :(

Craig T.

Maya Muchnik wrote:

> The same error is on pages 29 - 31.
>
> After reading your document, I have two questions:
>
> 1/ Is it possible to change a language on-line. For example one user uses English
> language with his browser, then he switchs to French. Can Struts handle this? I
> think, in your document the properties file is loaded in the beginning
> ActionServlet startup.
>
> 2/ How replace images with a text through properties file? (I think this question
> was posted already).
>
> Maya
>
> Maya Muchnik wrote:
>
> > Craig,
> > You have an error on page 28: not i8n, but i18n. I have got the explanations on
> > it.
> > Maya
> >
> >
> > > > >
> > > > > The Struts presentation I did can be found (at least for the time being)
> > > > > at:
> > > > >     http://www.us-eh.com/craiger/articles/struts/
> > > > >

--
I've been trying to change the world for years, but they just won't give me the
source code....


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


Re[2]: As promised (Struts Presentation)

Posted by Oleg V Alexeev <go...@penza.net>.
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: As promised (Struts Presentation)

Posted by Maya Muchnik <mm...@pumatech.com>.
The same error is on pages 29 - 31.

After reading your document, I have two questions:

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

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

Maya

Maya Muchnik wrote:

> Craig,
> You have an error on page 28: not i8n, but i18n. I have got the explanations on
> it.
> Maya
>
>
> > > >
> > > > The Struts presentation I did can be found (at least for the time being)
> > > > at:
> > > >     http://www.us-eh.com/craiger/articles/struts/
> > > >


Re: As promised (Struts Presentation)

Posted by Maya Muchnik <mm...@pumatech.com>.
Craig,
You have an error on page 28: not i8n, but i18n. I have got the explanations on
it.
Maya

Craig Tataryn wrote:

> <drool>Arrrrrgggghhhh, Dark Angel</drool>
>
> Ted, I'll cut the "only" word out of there tonight after I watch the
> aforementioned program.  But as far as I know, ActionForm is the only Model
> type class that Struts really manages for you auto-magically.
>
> Craig.
>
> Ted Husted wrote:
>
> > Kewl!
> >
> > I think I know what I'll be doning after Dark Angel tonight!
> >
> > I did notice one point on page 17, where it says "Struts will only
> > handle models in an automatic fashion if you extended
> > org.apache.struts.action.ActionForm"
> >
> > Is the word "only" accurate?
> >
> > I believe Struts works best if the form beans are ActionForm subclasses,
> > but I think the form and action would work just fine with any JavaBean.
> >
> > -Ted.
> >
> > Craig Tataryn wrote:
> > >
> > > ============================
> > > Craig M.: Can you add the link to the presentation (if you deem it
> > > suitable) to the resources section of the Struts User Guide?
> > > ============================
> > >
> > > URL forwarding sucks.  Given that, I will have to give you the link to
> > > the presentation as it exists on the server space I am borrowing until I
> > > get my own server box.  The URL may change in the future to my
> > > computer-programmer.org domain.
> > >
> > > The Struts presentation I did can be found (at least for the time being)
> > > at:
> > >     http://www.us-eh.com/craiger/articles/struts/
> > >
> > > Let me know of any problems or suggestions you may have about the
> > > presentation!
> > >
> > > Thanks,
> > >
> > > Craig.
> > >
> > > --
> > > I've been trying to change the world for years, but they just won't give
> > > me the source code....
>
> --
> I've been trying to change the world for years, but they just won't give me
> the source code....


Re: As promised (Struts Presentation)

Posted by Craig Tataryn <Cr...@msdw.com>.
<drool>Arrrrrgggghhhh, Dark Angel</drool>

Ted, I'll cut the "only" word out of there tonight after I watch the
aforementioned program.  But as far as I know, ActionForm is the only Model
type class that Struts really manages for you auto-magically.

Craig.

Ted Husted wrote:

> Kewl!
>
> I think I know what I'll be doning after Dark Angel tonight!
>
> I did notice one point on page 17, where it says "Struts will only
> handle models in an automatic fashion if you extended
> org.apache.struts.action.ActionForm"
>
> Is the word "only" accurate?
>
> I believe Struts works best if the form beans are ActionForm subclasses,
> but I think the form and action would work just fine with any JavaBean.
>
> -Ted.
>
> Craig Tataryn wrote:
> >
> > ============================
> > Craig M.: Can you add the link to the presentation (if you deem it
> > suitable) to the resources section of the Struts User Guide?
> > ============================
> >
> > URL forwarding sucks.  Given that, I will have to give you the link to
> > the presentation as it exists on the server space I am borrowing until I
> > get my own server box.  The URL may change in the future to my
> > computer-programmer.org domain.
> >
> > The Struts presentation I did can be found (at least for the time being)
> > at:
> >     http://www.us-eh.com/craiger/articles/struts/
> >
> > Let me know of any problems or suggestions you may have about the
> > presentation!
> >
> > Thanks,
> >
> > Craig.
> >
> > --
> > I've been trying to change the world for years, but they just won't give
> > me the source code....

--
I've been trying to change the world for years, but they just won't give me
the source code....


Re: As promised (Struts Presentation)

Posted by Ted Husted <ne...@husted.com>.
Kewl!

I think I know what I'll be doning after Dark Angel tonight!

I did notice one point on page 17, where it says "Struts will only
handle models in an automatic fashion if you extended
org.apache.struts.action.ActionForm"

Is the word "only" accurate? 

I believe Struts works best if the form beans are ActionForm subclasses,
but I think the form and action would work just fine with any JavaBean.

-Ted.

Craig Tataryn wrote:
> 
> ============================
> Craig M.: Can you add the link to the presentation (if you deem it
> suitable) to the resources section of the Struts User Guide?
> ============================
> 
> URL forwarding sucks.  Given that, I will have to give you the link to
> the presentation as it exists on the server space I am borrowing until I
> get my own server box.  The URL may change in the future to my
> computer-programmer.org domain.
> 
> The Struts presentation I did can be found (at least for the time being)
> at:
>     http://www.us-eh.com/craiger/articles/struts/
> 
> Let me know of any problems or suggestions you may have about the
> presentation!
> 
> Thanks,
> 
> Craig.
> 
> --
> I've been trying to change the world for years, but they just won't give
> me the source code....