James Greenberg

Greenhorn
+ Follow
since Jul 09, 2008
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 James Greenberg

Thanks for the info!
15 years ago
It is the "production" version that Sun is pushing. I only know that it's not fixed for this version of GlassFish. As GlassFish 3 gets final I'm gonna move to that one, or perhaps use Tomcat. Is tomcat better than GlassFish when it comes to JSF.
15 years ago
I have the latest one from Sun that comes with GlassFish v2u2 on Linux (Ubuntu 8.10) with all updates. I actually earlier posted about this issue on another thread (the last reply):
http://www.nabble.com/JSP-FORM-based-authentication-redirects-to-expired-session-context-td19499341.html#a20785271
15 years ago
thanks, I implemented your suggestion but the exception doesn't get caught by that page, but the servlet mentioned above does, so I'm happy that at least that one works.
15 years ago
By "I had a look at it but I don't need it" I mean I don't need to know the nature of the error since I know exactly why it happens (in my scenario).
15 years ago
Yeah I had a look at it but I don't need it, I only needed to catch the hideous Exception I get using Sun's JSF: when the session times out and the user clicks a submit-like button in a (JSF) form - the user gets a screen of errors and doesn't know what to do, I needed a way to catch that error and send the user to the main page in a user-friendly fashion. I tried to catch that Exception from "usual Java code" and nothing worked since the error raises inside the JSF implementation. I started thinking dropping JSF altogether or implementing my own exception handler. Luckily implementing it turned out to be much easier than I expected.
15 years ago
Thanks a lot,
I thought I would need to explicitly implement some kind of exception interface or method(s) with custom parameters, but in reality it turns out much simpler, you just create an usual servlet and change the web.xml file for errors to be sent to this servlet and what you do further is up to you.

thanks again.
15 years ago
Hi,
I'd like to create and use my own exception handler in GlassFish 2.
By default GlassFish uses the one predefined in web.xml:
<servlet-mapping>
<servlet-name>ExceptionHandlerServlet</servlet-name>
<url-pattern>/error/ExceptionHandler</url-pattern>
</servlet-mapping>

Does anyone know any tutorial on creating and applying my own exception handler (to GlassFish)?
This might be considered a bad decision but I really need it.
15 years ago
Hi folks,
Inside a <h:dataTable> (running GlassFish v2) I have this code:

showUserInfo - is a JavaScript function which opens a new window, but JSF renders the code by appending a jsessionid which results into a JavaScript error on the client-side when the user clicks the link, because it is rendered like this:

The jsessionid is appended when the user first visits the page, or when he restarts the browser and comes back to this page.
I tried replacing h:outpuLink by <a href> but since the code is inside an h:dataTable the JSF throws an error about bad code.
Any hints on how else to try to solve this issue?
15 years ago
JSF
Thanks a lot both of you,
as it turns out (I've done some tests), the JSP code is evaluated first, this makes a lot of difference in my case as I thought the page just executes from top to bottom regardless, that's why my code executed in such a weird fashion.
My problem was/is: I (once again) underestimated the (golden) rule: never ever mix JSP and JSF code inside the same file if you don't wanna spend days/weeks later debugging.

SO I replaced the JSP code with the JSF counterpart and anything works fine.. so far..
15 years ago
JSF
When I need something like what you're asking for I do that by setting the corresponding property in the bean manually. Pseudo code for the managed bean:

and before using the session you actually have to set it from your JSP page:
MyBean mb = (MyBean) session.getAttribute( "MyBean" );
mb.setSession( session );

Same applies to other stuff.
15 years ago
JSF
Hi folks,
I have a <h:dataTable> (running on GlassFish v2ur2), where a column should display the price unless it's not empty (the price's string length >= 1):

The problem is that the <c:if> works weird, it doesn't print anything, regardless of whether the price's string length is greater than 1 or not:


I'm afraid it could be some JSF/JSP interoperability issue, I would appreciate any comments.
[ November 15, 2008: Message edited by: James Greenberg ]
15 years ago
JSF
Hi,
perhaps this question has been asked several times, I googled but couldn't find the answer.
Say I have an <input type="text"> element and I want to register a listener that would receive events every time the user enters or deletes characters and a way to dynamically set text into some other widget all of this without the user having to hit the submit button. Sounds like Ajax, but can I avoid using Ajax directly through some abstraction layer of JSF and JavaBeans?
If that's possible a link to where I can read the details would be great.
15 years ago
JSF
Hi,
I hope I understood you correctly, unless it has been answered somewhere else,here's how I solved it: so you create the component GUI and bind it to the managed bean that fetches the info from the DB.
In my case I needed a class that fetches several country names, the final result looks like this:

The gui component:
<blockquote>code:
<pre name="code" class="core">
<h:selectManyListbox value="#{CountriesBean.selectedItems}" size="8" styleClass="defaultText">
<f:selectItems value="#{CountriesBean.selectItems}" />
</h:selectManyListbox>
</pre>
</blockquote>
The CountriesBean.java class is declared in faces-config.xml like this:
<blockquote>code:
<pre name="code" class="core">
<managed-bean>
<managed-bean-name>Countries</managed-bean-name>
<managed-bean-class>xlinuks.Countries</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</pre>
</blockquote>
Its source code:
<blockquote>code:
<pre name="code" class="core">
package xlinuks;

import javax.faces.model.*;
import java.util.*;

public class Countries {

List<String> selectedItems; // + getter + setter
List<SelectItem> selectItems; // + getter only

public Countries() {
}


public List<SelectItem> getSelectItems() {

if( selectItems == null ) {
//so it actually calls another class called Connector
//that fetches the data from the DB
selectItems = Connector.getCountries( language );
}

return selectItems;
}

public void setSelectItems( List<SelectItem> selectItems ) {
this.selectItems = selectItems;
}

public List<String> getSelectedItems() {
return selectedItems;
}

public void setSelectedItems( List<String> selectedItems ) {
this.selectedItems = selectedItems;
}
}
</pre>
</blockquote>
These are the main steps, unfortunately I can't post a detailed description.
15 years ago
JSF
I'm sorry, in my first post the first snippet was not accurate, I have to use <%=sLocaleLang%>, ${sLocaleLang} doesn't seem to work since it's a regular String var that I create like this:

Thank you for your post/idea(s) I will consider them as well.
At the end of the day I wish there was the (exact)JSF equivalent for the JSP code, but who knows, perhaps there's a good reason for it not being there or it's there but I don't know about it.
15 years ago
JSF