Vince Kennedy

Greenhorn
+ Follow
since Aug 26, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vince Kennedy

Chandella Montero wrote:Why? I still don't understand.

What happens if you pass an int?



It's a compile error. It's been a little while since I've been through this completely, so double check my explanation.

If you have a a method that takes an Integer... (var args of Integer Objects), passing an int (I believe) is fine since you have wrappers.

If you have a method that takes an int...(primitive var args), passing the primitive is again fine - just a different number of var args.

But if you have both, I believe both are viewed as 'objects' of sorts (Integer Array and int array) and the compiler finds the call ambiguous.
I got it to work by changing the navigation-rule to this:


So the view-id needs to reference the actual view names? i.e. the url I type is /test.jsf (and it has the servlet mapping) but for JSF redirection it needs to be the actual file name, i.e. *.jsp?

I thought you (Tim) had said it only referred to the URL, but since there's no servlet mapping in JSF navigation is that why it works with *.jsp, but *.jsf?
13 years ago
JSF
I've been playing around with this all day and reading various examples trying to figure out the problem.

I do notice when this is the setting, I get a warning that action value does not match a navigation outcome.


But my navigation rules are the same:


And if I change from-outcome to from-action with this:

It still won't navigate for me. The action method is in mypackage.MyBean.java:


13 years ago
JSF

Tim Holloway wrote:navigation is to URLs, not to resources. Therefore your rule must specify a URL, giving us:

3. If the destination URL cannot be resolved, no navigation can occur.

Actually, I thought this was supposed to result in a "404" error, but at any rate, it can't succeed.


Well I had been playing with the faces-config.xml so the <to-view-id> value is now '/hello.jsf' - that seems to be correct.

I added the error messaging stuff to the test.jsf and the messages worked (since I had to play around with ID's or it was printing error messages, now it prints none).

test.jsf and hello.jsf are both on the same level of the WebContent folder, and test.jsf works beautifully, so the path should be working.

I was guessing for some reason the actual navigation-rule wasn't getting invoked by the buttonCommand for some reason, hence no 404 or other error. It does nothing after the button click.
13 years ago
JSF

Tim Holloway wrote:1. Failure of one or more fields in the form to validate (hint: include an "h:messages" element on the view containing the form).

2. Failure to find the action method. This can happen if the action method does not exist, the name is misspelled/miscapitalized, or if it doesn't have the proper signature: "public String xxxxx()". No error will display in this case. Failure is silent.


Thanks Tim, I appreciate all the help in my fumbling through JSF so far.

1. There is the h:messages element on the containing form - but do I need to set options so the errors would display? It seems all of the flags that I can set in it are for error/info styles and not displaying the errors.

2. I was using the BalusC JSF Tutorial (great set up tutorial btw), and he had turned off that warning so you could have void action Methods. I switched it the method to return a string value. Here's the code:


So to make sure I understand the redirection process, the action field of <h:commandButton> calls myBean.action, because that's what I set it to. Then the redirection is on test.jsf, so when the action is done it should automatically be moving on to hello.jsf.

Now one thing I was mildly worried about if I do /test.jsp - the page won't display, it has to be /test.jsf even though the actual file is .jsp. So on the redirect URL should it be /hello.jsp for the file name or /hello.jsf because it needs the jsf extension to be recognized?
13 years ago
JSF
I'm working on this and got everything I needed set up and running. So now I was playing around a bit more to see if I could develop a simple site.

But I'm having issues with redirection.

This is the navigation rule I'm using.



And this is the form in test.jsp


The MyBean class is just an input and output string with getters/setters and a public void action() that sets the output message. I do know the file is named test.jsp and the redirection uses /test.jsf, because that's the URL i have to use to get to the page because of the web.xml. The problem is that it won't change pages no matter what I do.

I've been reading through other pages and everyone seems to handle button clicks and page redirection a little different so I can't tell if something with a code block is wrong, or if I'm missing the whole point on navigation. Any help would be appreciated.
13 years ago
JSF
Well if I remove some of the 'extra' stuff and just do



instead of



The box will appear. It doesn't like the <h: /> tags for some reason. I'm sure it's related to the error message up top, which disappears if I delete the definitions. I'm pretty lost on it.
13 years ago
JSF
I'm working through a JSF Tutorial (JavaServer Faces 2.0 The Complete Reference), and I created an xhtml file and it's running on Tomcat 6.0

When I pull up the page the text will display but none of the edit boxes, radio buttons, buttons etc will display. If I highlight it, it seems like table is being formatted just nothing displaying. In the file I get this error:

Multiple Annotations on this line:
The content of element type must match "(head, body)"
Attribute "xmlns:h" must be declared for element type html
Attribute "xmlns:f" must be declared for element type html



This is the xhtml file, I clipped some of the inner code to shorten it, but it's all pretty much the same.



Has anyone seen this before? There are no errors on the console from the server, just no display.
13 years ago
JSF

Tim Holloway wrote:

Tim Holloway wrote:The message you got from Tomcat 5.5 was probably because 5.5 JSF webapps also requires the EL jar that's part of Tomcat 6.

I'm not sure about the html error. The first message I think would require being able to see some more of the HTML than just the outermost element. The 2 namespace errors shouldn't be happening if the jsf-api jar is located in the apps classpath, since that's where those definitions are stored.



BTW, it's usually better to start a new thread. Otherwise we sometimes end up with conversations on 2 different subjects and that can not only be confusing, it can make it a little harder for people who use the forum search.


I wasn't totally sure if it was a related issue or not.
13 years ago
JSF

Tim Holloway wrote:Hello Menen, welcome to the JavaRanch.

When you create a JSF webapp, you must include the JSF api jar as part of the webapp, and like all library JARs for a J2EE WAR, that means you put a copy of the jsf-api.jar in the webapp's WEB-INF/lib directory.

Tomcat is not JEE 5 compliant, so the actual JSF implementation classes aren't a standard part of Tomcat the way they are in full-fledged JEE servers. So you have to also include the jsf-impl.jar in WEB-INF/lib.



Tim,

Thanks for the info on this, I was running in to the same problem as well and got it working. I did also find you needed to run it on 6.0 because 5.5 will cause a separate error.

I'm not sure if this is the proper area, but when I go to the page I created as part of a JSF Example I'm working on, none of the edit boxes, radio buttons, drop downs or buttons I had created seem to be displaying. In Chrome if you highlight it, it seems like the grid layout is there but nothing is showing up. There is a fairly cryptic error at the top of the xhtml file I'm using. The code is:


And the error reads:

Multiple Annotations on this line:
The content of element type must match "(head, body)"
Attribute "xmlns:h" must be declared for element type html
Attribute "xmlns:f" must be declared for element type html



I'm not entirely sure what this means, because it seems those attributes are declared.

Thanks for any help anyone can offer.
13 years ago
JSF
I don't suppose Sun is offering a free retake right now?

I couldn't see any info on it.

Ankit Garg wrote:

i.e. the Run2 r2 = (Run2)r; isn't two instances of the same thread, but two threads with the same instance of runnable? So calling start on each is legal?


The line you mentioned just creates a sort of alias to r. Neither does it create two instances of a thread, nor it creates two threads with the same runnable. It is just a plain assignment.


Ok, but if this is just a simple assignment/alias statement, does that mean there are two references to the same thread? So how come you can start them both?

There are either two thread instances here or two references to one thread instance. If it's two thread instances, using one runnable then I suppose I understand why the output is 1 2 3 4. If it's two references to one thread, I don't understand how start can be called on the same thread through two references.

Neha Daga wrote:because the runnable object instance passed to both threads is same. If you had created a new runnable object and passed it to second thread then it would have been 1 2 1 2.


So you can have two threads with the same instance of Runnable? i.e. the Run2 r2 = (Run2)r1; isn't two instances of the same thread, but two threads with the same instance of runnable? So calling start on each is legal?
It asks for the output after the code is executed:



When I read through it at first it seemed there were two separate threads being started, and since Run was synchronized and x is a member variable (initialized to 0), the first call on start would return 1, and 2. Then when the second thread started, it would also print 1 and 2.
It was wrong, and the answer seems to be 1,2,3,4 - as if there is only one instance of x. But it's not a static variable, is it? So for x to be the same variable accessed by thread1 and thread2, would it have to be the same instance of a thread? And you can't start the same thread twice, correct?

So why is x holding it's value in this code?

Thanks.

Bauke Scholtz wrote:Make sure that the request URL matches the url-pattern of the FacesServlet entry in web.xml. This way the request will be passed through the FacesServlet, which on its turn creates the FacesContext. Otherwise the JSF components in the JSP page will complain that the FacesContext cannot be found and hence this exception.

If the url-pattern is for example *.jsf, you should be invoking the page as /page.jsf, not as /page.jsp.



I'm having this same issue.

I was running through this tutorial and I'm getting the same error. If the url doesn't match the XML mapping I get the requested resource is unavailable. Then I match it up and I get the Cannot find FacesContext.

Thoughts?
14 years ago
JSF