• Post Reply Bookmark Topic Watch Topic
  • New Topic

General problems with some beginner stuff  RSS feed

 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I was all of a sudden given a jsf project by a company because I won a challenge at my school. However, I am essentially a java beginner, and I am totally new to jsf. I've been doing a lot of tutorials and a lot of research of course, and I've gotten some good knowledge. So now I'm trying to do my own simple project but am running into trouble.

Basically, the first page in my project asks the user for a project name and project description. Then when the user hits submit after inputting the text, I want it to go to a results page and display the text the user just entered. I can get the initial page to load up, unless I try to bind the input text to the appropriate attribute (in other words when I add value="#{ProjectBean.projectName}" required="true" to the inputText tag).
When I add that in it will not even load the initial page, it gives me a long list of error. Thats the main issue I have, and Im not sure where to go for help on it. So Im hoping someone will take a look at my source code and give me some tips. Additional help besides the problem I mentioned will be appreciated too, because Im sure Im doing other things in an incorrect manner.
Thanks a lot, since I am not alllowed to upload a zip file... I will just have to post the code here in the forum I guess

The source code is very short and simple btw, anyone with any experience at all should be able to pretty quickly figure out my problem I would assume. Oh and another thing, Im not getting any errors, just some warnings in Eclipse.

faces-config.xml


web.xml


index.jsp


mainpage.jsp


results.jsp


ProjectController.java
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For starters: never ignore errors. Take them for serious. They tell something about the cause of the problem. Once you understand it, solving it will be easy. In many cases just googling the exception type, message and if necessary the 1st line of the stacktrace will deliver enough answers on the web.

If you stucks, just post the exception and the stacktrace here and we will explain the cause so that you understand it and be able to solve it.
 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bauke and thanks for the response. I am at work right now but as soon as I get home I will post the errors as well as the stack. I know the problem has to lie most likely with the mainpage.jsp code, but I suppose there could be a problem with ProjectController.java too.
 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, first the errors:

on mainpage.jsp "required" is what seems to be causing the error. The error is 'Undefined attribute named "required"' on the following line of code:



also on mainpage .jsp I get the exact same thing on "required" on another line of code. Also on this second line of code #{ProjectBean.projectDescription) is underlined and the error says 'Expression is not gettable'. Although sometimes that "Expression is not gettable" error seems to disappear, its very odd. Here is the line:



Finally, on another line I am getting #{ProjectBean.saveProject} underlined, and the error says 'Method must have signature "String method()" but has signature "void method()"'. Here it is:



I think I have that last one figured out, but probably not lol.

And finally, here is what I get when I go to http://localhost/addproject. It should be noted when I remove required="true" or value=#{} from the end of those two lines of code the page loads fine so those two items have to be the problem. It is very frustrating I have to say, I hope someone can help me



thats all, Im sure the probelm lies on mainpage.jsp as well as ProjectController.java but I cant figure it out after hours of changing things. I cant wait for the JSF textbook I ordered to arrive...
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matt Kohanek wrote:OK, first the errors:

on mainpage.jsp "required" is what seems to be causing the error. The error is 'Undefined attribute named "required"' on the following line of code:
The attribute is unknown. The tag simply doesn't support this attribute. Usually only UIInput tags supports it.

Also on this second line of code #{ProjectBean.projectDescription) is underlined and the error says 'Expression is not gettable'. Although sometimes that "Expression is not gettable" error seems to disappear, its very odd. Here is the line:
There's either a typo in property name or the associated getter method is missing in bean class.

Finally, on another line I am getting #{ProjectBean.saveProject} underlined, and the error says 'Method must have signature "String method()" but has signature "void method()"'. Here it is:
Void is indeed allowed. The IDE you're using is maybe too strict. From what I know is that the latest Eclipse release is indeed too strict on this (showing error instead of warning). Also see http://balusc.blogspot.com/2008/01/jsf-tutorial-with-eclipse-and-tomcat.html



org.apache.jasper.JasperException: /mainpage.jsp(9,8) Attribute required invalid for tag outputLabel according to TLD

This is fairly self-explaining, isn't it? Remove this attribute.

For an overview of valid tags and attributes refer the TLDDOC.
http://java.sun.com/javaee/javaserverfaces/1.2_MR1/docs/tlddocs/
 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I removed the results="true" components altogether. I was just copying that from a tutorial and figured it was necessary.
Now the page will even load too. But when I hit submit it will take me back to the mainpage.jsp and not results.jsp...but I will try to deal with that in time.

The last issue I need to figure out here is why ProjectBean.projectDescription is "not gettable"

I checked for typos and found none at all, any hint on where I should focus for typos?

Also, I know the getter method is indeed there, but I'm sure something is wrong. The .java code is posted in the first thread, so if you get a chance to look at it that would be helpful. If not I understand, it is a lot of code to go over.

And I went through that BalusC tutorials, it was one of the first I did. It was very useful for me.

I will work on trying to figure out how I can actually make required="true" work, because I'm guessing that is the reason why my navigation rule isnt taking me from mainpage.jsp to results.jsp

Oh if only there were more time in a day
 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, thank you for the help. Ive already gotten some great insights such as heeding even the warnings as well as analyzing the first line of the stack. Very helpful stuff
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matt Kohanek wrote:But when I hit submit it will take me back to the mainpage.jsp and not results.jsp...

Either a validation or conversion error has occurred which missed your attention, or the navigation case configuration is bogus.

To determine the first, add a <h:messages/> component to the page so that you get notified of any missing message, or add a <h:message/> to every input component to display specific message for the component, or -only if you're using JSF 1.2 or newer- read the appserver logs; they will be logged there as well.

The second is maybe a bit trickier, but you need to make sure that the 'from-view-id' and the 'to-view-id' needs to be exact the same as the file system path with the webapp context as root.

The last issue I need to figure out here is why ProjectBean.projectDescription is "not gettable"

I checked for typos and found none at all, any hint on where I should focus for typos?

Also, I know the getter method is indeed there, but I'm sure something is wrong. The .java code is posted in the first thread, so if you get a chance to look at it that would be helpful. If not I understand, it is a lot of code to go over.

You need to have a public SomeObject getProjectDescription() {} method in your ProjectBean.

And I went through that BalusC tutorials, it was one of the first I did. It was very useful for me.

Thank you that you like my tutorial.

I will work on trying to figure out how I can actually make required="true" work, because I'm guessing that is the reason why my navigation rule isnt taking me from mainpage.jsp to results.jsp

First of this, what do you think that this attribute does? What have you learned from it? What do you expect of it? Maybe it is completely wrong and thus ' not working' as you'd initially expect.
 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh so that tutorial was yours then? Very good work, it was actually the first tutorial I did that I was able to get a working program out of, very detailed.

OK, I am at work again so I will just address the part of your response I know about without having to be in front of my laptop.

I thought results="true" affected the navigation rule I put in faces-config.xml. I'll post the navigation rule first to make it easier to describe:



I thought results="true" was somehow coorelated to <from-outcome>success</from-outcome>
In other words, I thought that once the compiler saw there was text in each of the input boxes, the results would be "true" which would then invoke the navigation rule. Now that I think about it, it is probably more tied to the submit button though I would imagine.

I got the idea from a calculator program tutorial by Richard Hightower (JSF for Nonbelievers: Clearing the FUD about JSF))
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no 'results' attribute. It's called the 'required' attribute.

Does it make any sense if you know the fact that this attribute is only available in input components?

The navigation case outcome is just based on the return value of the bean action method.
 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah of course, I see now.
So if I want that navigation rule to work, somewhere in my .java code I need to include - return "success";
I got it now. Man I love this stuff, I always feel so good once it all makes sense in my head.

edit: sorry, I was referring to required="true" as you inferred, I just got the words mixed up
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.

And indeed, if you want to make use of navigation cases, you need to let the action method return the desired outcome.
 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have any other tutorials (that you made) that you think may be relevant to my situation?
I know I need to learn more about JSF, CSS, JavaScript, EJB (I have no idea what this is yet), and I need more html/xml knowledge.
If you have any other tutorials please link the main page so I can browse through them.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the client side languages, I can recommend the tutorials at w3schools.com.
For the server side languages, I can recommend the tutorials at sun.com.

E.g. Javascript: http://google.com/search?q=javascript+tutorial+site:w3schools.com
JSF: http://google.com/search?q=jsf+tutorial+site:sun.com (oh, make sure that you pick the newest, which is only the 2nd google hit)
 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought you might want to know why that one bean kept telling me it was not gettable.

I had the set method named setProjectDescription(), but the get method named getDescription() instead of getProjectDescription(). Once I changed that it fixed the problem. Then I just had to add return "success"; to my saveProject() method and my navigation rule worked too! Its working exactly as I intended now.

Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!