Win a copy of Terraform in Action this week in the Cloud forum!

gary stines

Greenhorn
+ Follow
since Mar 11, 2002
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 gary stines

Session scope for page1 would work. But can anyone still explain the behaviour as mentioned before.

(Thanks for the reformat Gregg)
16 years ago
JSF
Can someone explain the following behaviour

I have two pages page1.jsp and page 2.jsp each with managed beans called page1 and page2 respectively in the request scope as shown below


page1 has a selectOneMenu. I also have a command button on page1 which goes to page2. Page2�s purpose is to collect information to add a selectItem to the selectOneMenu on page1.

Partial code shown below, values hardcoded for clarity. The idea here is to save the contents on page1 in some session scoped object, in the page2 action method create a fresh page1bean, update it with the original values, then redisplay page1 with the newly updated values



When I am returned to page1.jsp I see the selectOneMenu list has been updated and everything looks fine. The problem occurs when I then hit the submit button on the redisplayed page1. The item I added disappears from the list.

What�s happening here?

The only happens with the selectOnemenu component. Other inputText components work fine.
[ May 12, 2005: Message edited by: Gregg Bolinger ]
16 years ago
JSF
This is what I did...

In the action method on the page1 bean I created the bean that is used for page2

Page2Bean pg2 = (Page2Bean )fc.getApplication().createValueBinding("#{page2}").getValue(fc);

where page2 is the managed bean name.

You should create a binding on page2 to a corresponding property in the Page2Bean. You then modify this property to reflect the changes on page2
16 years ago
JSF
How can I programatically get the label value from a selectOneMenu tag

<h:selectOneMenu value= "#{person.personid}">
<f:selectItems value="#{person.personList}"/>
</h:selectOneMenu>

I can access the personid in the backing bean, but how can I easily access the corresponding label value
16 years ago
JSF
I know I probably had to use some session scoped object, I guess what I was really asking are what best practices/patterns others are using.

Could a pop window be used? This should leave the initial screen and its values intact.
16 years ago
JSF
I have a page with a request scoped backing bean. One of the input parameters on this first page is created by navigating to another page. After leaving the second page I would like to return to the first page displaying its new value in the input field.

How can this be done leaving the first page backing bean in the request scope.

I could set the backing bean on the first page as session scope, but I would have to initialise the bean every time I navigate to that page.
16 years ago
JSF
Thought about that. But I guess I would have to test for the empty string and then manually set the backing bean attribute to null, or does jsf automatically convert an empty string value to null? Also how would you handle other values other than a string

eg new SelectItem(new BigDecimal(0), "none")

0 could be a possibly selection value for my list.
16 years ago
JSF
In creating a selectOneMenu item I am using a child selectItems tag. How can I bring in the concept of a null value or a 'no selection option'. In other words can one of my selectItem objects look like this

new SelectItem(null,"none").

When I tried the above code I get a nullPointerException when rendering the page.
16 years ago
JSF
I have used it with 5.0.27 and 5.0.28
16 years ago
JSF
Get both by David Geary and Kito Mann.

Read Geary first. Geary much easier to read and understand from a beginners perspective.

Read Kito second. Kito goes into more detail.
16 years ago
JSF
<h:inputText value="#{policy.testDate}" id="received">
<f:convertDateTime pattern="dd-MMM-yyyy"/>
</h:inputText>

when using the above code in a jsp page I get the following error

java.lang.IllegalArgumentException: argument type mismatch

This occurs when testDate maps to a java.sql.Date object in the backing bean. It seems to work ok when I change testDate to a java.util.Date object.

Question, does convertDateTime only work with a java.util.Date object. I thought it should work with java.util.Date and all its subclasses which would include java.sql.Date.
16 years ago
JSF
html ide.. something similar to dreamweaver ie to build the web user interface. i haven't used any java ide's but I am guessing most only support the building of swing user interfaces within the ide(using gui tools). I have looked at jdeveloper it allows you to import html pages and manipulate within the ide, but as far as i know jdeveloper doesn't allow you to create a jsp page from scratch using gui tools, you can write html code(for a jsp page) within the jdeveloper ide using something similar to a text editor.
I hope you understand what I am getting at, correct me if I am wrong in any assumptions made above
are there any java ide's that also has a builtin html ide. Reason being having a one stop shop to manage/create jsp pages/servlets/ejb in a web application
I did think about saving this information in the session but I was also thinking that there may be problems storing all these objects in the session. This may lead to memory problems within the JVM particularly with a web application(large number of users).
In other other words wouldn't it be better for the database to handle this type of situation rather than leaving it to the servlet container.
Also regarding the question about the user leaving the machine in the middle of a transaction. I could have the session timeout say within 10 mins and handle rollback/cleanup within the HttpSessionBindingListener interface using the valueUnbound method.
19 years ago
I am creating a web application using a mvc jsp/servlet architecture. I am having a problem deciding how to maintain transaction state across multiple pages. Eg I have say three jsp pages which will each save information to separate database tables which comprise a single transaction. The problem arises when the user decides to hit the back button and goes back to the first page, at this point in the transaction three records have already been posted to the database (not comitted as I have set autoCommit to false). Now if the user decides to make changes to the first page and hit the submit button I would essentially like to rollback all transactions to that first page and start over again.
if the user decides to hit the back button to the second page(coming from the third page) I would like to rollback to that point only.
I hope you see the general trend. Of course the rollback would only occur when the submit button is pressed on the page you backed up to.
I have seen solutions by setting tokens in the request and session objects, but this only allows you to perform the transaction only once.
Now I was thinking that when processing each page I could set a savepoint and manipulate the rollback scenarios as described above theoretically( haven't tried it as yet)
Questions
1)is this feasible?
2)I think savepoints are only available from jdk1.4 and up how would I implement under jdk1.3
3)What is the best practice to follow in such scenarios?
Any links, all advice would be highly appreciated.
Gary
19 years ago