*
The moose likes Struts and the fly likes anyone face Error - tag.getAsString : component context is not defined? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "anyone face Error - tag.getAsString : component context is not defined?" Watch "anyone face Error - tag.getAsString : component context is not defined?" New topic
Author

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

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
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 ]
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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());


A good workman is known by his tools.
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
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

Joined: Jan 08, 2004
Posts: 834
anyone can help ?
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
any friend can help ?
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
anyone ?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Matt Raible
author
Ranch Hand

Joined: Jan 11, 2001
Posts: 114
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?


Matt<br /> <br />Author: <a href="http://springlive.com" target="_blank" rel="nofollow">Spring Live</a> and <a href="http://www.apress.com/book/bookDisplay.html?bID=256" target="_blank" rel="nofollow">Pro JSP</a><br />Weblogs: <a href="http://raibledesigns.com" target="_blank" rel="nofollow">Raible Designs</a> <a href="http://jroller.com/page/raible" target="_blank" rel="nofollow">Spring Live Blog</a>
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
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 ]
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
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.


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, somkiat puisungnoen , my parameter for url will be C:\mycrmtest\template\layout2\layout2index.jsp

what do you means by get rid of "/" ?
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
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

Joined: Jan 08, 2004
Posts: 834
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

Joined: Jan 08, 2004
Posts: 834
anyone see Error - tag.getAsString : component context is not defined. Check tag syntax before ?
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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

Joined: Jan 08, 2004
Posts: 834
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
 
 
subject: anyone face Error - tag.getAsString : component context is not defined?
 
Similar Threads
Call an action defined within another package
Struts help
[URGENT]Problems with Struts and Tiles
Struts 2 hidden values
Problem with including an action