• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

anyone face Error - tag.getAsString : component context is not defined?

 
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, good day, i have a question something on action,

program description :

in the action class, there have one variable from actionform which is actually URL address, and this URL address will determine which page to call, example for this variable : "..\jsp\callpage.jsp ", and this variable is changeable

now, as for action's mapping.findforward("success"), will call the page based on String inside the findforward() method, in this case, "success" , and then will call the page that have been defined for "success"

my problem is how do i pass this variable and make my action call the variable's defined page ("..\jsp\callpage.jsp ")?

thank you very much for your time !!
[ October 28, 2004: Message edited by: Alvin chew ]
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe that what you are attempting to solve by passing the URL has a better solution. However, without knowing WHY the form is holding such a URL, I can not offer a better solution.

To answer your direct question, try:
return new ActionForward(yourForm.getYourURL());
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, marc , what i'm doing is actually a component for user interface customization, i have few popup form which allow user to key in and select the user setting for new web interface,

my idea to do this is after user keyin all setting, the data keyin will pass to several class, these class may include say foldercreator class, navigationlinkcreator class, indexpagecreator class and so on for create respective pages which will use for template of Tiles..

and what i need to do is after all these page been created, i need to call the indexpage in order to display the new interface, so my logic is i need to pass this indexpage url and display it after the actionmapping successfully match ..

so marc or other friends, do you have any idea for my solution ? thank you !
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anyone can help ?
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any friend can help ?
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anyone ?
 
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alvin,
If you have a finite number of layouts, you could use Struts forwards. If not, you may want to reconsider your approach. Maybe use a stylesheet? Struts doesn't let you forward to an arbitrary page.
 
author
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark's approach should work - just create an ActionForward on-the-fly using new ActionForward(url). You could return this URL at the bottom of your method:



There are many ways to create an ActionForward. Does this suite your needs? If not, why? Have you tried it?
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, matt , by try the provided solution , i get error like

error http 500 -
java.lang.IllegalArgumentException: Path C:\mycrmtest\template\layout2\layout2index.jsp does not start with a "/" character

is it means i need to convert it into /mycrmtest/template/layout2/layout2index.jsp as my parameter for new forwardaction ?

thank you !!
[ October 27, 2004: Message edited by: Alvin chew ]
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Alvin chew:
hi, matt , by try the provided solution , i get error like

error http 500 -
java.lang.IllegalArgumentException: Path C:\mycrmtest\template\layout2\layout2index.jsp does not start with a "/" character



get rid of "/" in first position of url.
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, somkiat puisungnoen , my parameter for url will be C:\mycrmtest\template\layout2\layout2index.jsp

what do you means by get rid of "/" ?
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Alvin chew:

is it means i need to convert it into /mycrmtest/template/layout2/layout2index.jsp as my parameter for new forwardaction ?



Have you tried that? You're not using a file path are you? Are you actually passing "C:\mycrmtest\template\layout2\layout2index.jsp" as your path for an ActionForward? You want to use a URL to your jsp relative to the document root of your web application. It will probably be something like "/template/layout2/layout2index.jsp".

Anyway, as others have suggested, you can simply dynamically instantiate an ActionForward on the fly. Instead of the following in your Action...



...you can do something like the this instead:



Notice that the url is not a path to a file on my computer, rather it is a URL to a jsp on the server, which in this case is relative to my context root.
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you , jason , i think it work , but another problem turn on ...

this problem happen when i call action with return new ActionForward(ic.getURL()); which is suppose call layout2index.jsp , but it generate error code as follow :

error :


this is the index file that i call from Actionforward : layout2index.jsp


this is layout page that will call from layout2index.jsp : layout2layout.jsp


is that any problem from layout2layout_jsp ? thank you !!

[ October 28, 2004: Message edited by: Alvin chew ]
[ October 28, 2004: Message edited by: Alvin chew ]
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anyone see Error - tag.getAsString : component context is not defined. Check tag syntax before ?
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alvin,

Sorry I did not respond to your private message earlier. I do not check it often.

Anyway, your current tiles problem I believe is in your opening tiles:insert tag - it has a / which closes the tag, ignoring the tiles ut tags below it that you meant to include.

As to the earlier discussion of which method to use is best I'm not sure if I 100% understand what it is you are creating. My own personal rule is to try and develop in such a way that the ActionForward(s) being used come from the struts-config file. I try to never pass around urls (and for me it would be pointless to do so as I keep my application jsps in the WEB-INF folder).
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, marc , have a nice day, you are right .., i do all careless mistake ..very appreciate your reply ..and i would like to thanks again for your help
 
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic