Yeray Santana Borges

Ranch Hand
+ Follow
since Mar 02, 2008
Las Palmas, Spain
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
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 Yeray Santana Borges

Hello,

I have already done this question in Oracle forums, but still I have not a response. You can see the thread here https://forums.oracle.com/forums/thread.jspa?threadID=2378190&tstart=0.
I am trying to share information between one view to a new window opened as popup. I am trying to use flash to share information, currently I don't know if flash can be used for this. This is my question asked in Oracle forums:


I am trying pass a java object to a popup window after a jsf ajax request. When the user clicks on a h:command button, the application does an ajax request. In an actionListener method of a session scope managed bean I create a big object with data. When the ajax request returns to the client, I am opening a popup window to show the data of the object created in the previous action listener method.

I don't want save the object in the session and I cannot use the object like a request managed bean, because the ajax request finish before than the popup is opened, and the popup is opened in a different page and a Request Scope bean it is not available in the new request.

I thing that I cannot use a View Scope bean to save the object, because the popup is a different view. I cannot use view params because I need a converter to transform the object created in String properies and the object has many properties. Now I am trying to pass the data from the main window to the popup using the flash scope. But I cannot do a sample page to pass data between a main window and a new page opened in a popup.

Look at the next sample:

index.xhtml


ControlledBean.java:


popupwindow.xhtml



RequestBean.java is a simple POJO



At the end the input "result" in popupwindow.xhtml shows nothing, I am trying to see in this input the value "Value created in ActionTest". Any help, tip, sugestion?

Thanks for your time.


8 years ago
JSF
I think that your code is doing something wrong in the getter and setter of nomComposant and typeFile. Could you write them?, what is the scope of your bean and how are you initializing the nomComposant and typeFile variables?

In my opinion you should remove the setPropertyActionListener, I think that you don't need them.
When you are clicking on commandLink "rejouer", first you are getting the value of nomComposant to assign it to nomComposantARejouer (getters and setter will be called before your code enter in rejouerMessage() method), maybe you can use directly the value of nomComposant in your backed bean when you are in rejouerMessage(), something like this:


8 years ago
JSF
What seems to me incongruous is what is needed as a classroom course like "Java Programming Language, Java SE 6" someone who is already certified as Java programmer SE 6

Could someone give me a solid argument on this issue?
Mmhhh, sure, that's exactly what I need. Now all I need is to have an EJB 3.1 container in the upcoming applications, but that's another thing.

Thanks for your response. Regards
Hi,

In some project, sometimes I have found a similar requirement, cancel the execution of a process that take long time. For example, the user clicks in a button, this action trigger a process that calculate data an while the process is running, the user see a cancel button with a please wait message.

If the user clicks on cancel button, the transaction that was opened in the first request is marked as rollback and the execution of the process is stopped. With early technologies as EJB 3.0 or without an ejb container, sometime is difficult implement this logic to get the open transaction in a previous request from a new request to cancel it.

How EJB 3.1 can help me in similar situations??
Hi,

I have doubts about the processing lifecycle of a JSF application if there are two different requests from the same user. For example, suppose an application with two buttons:

Button 1 --> A load button connected to a actionListener method that load a lot of data from data base that will be showed in a table.
Button 2 --> A Cancel button with immediate=true and connected to a action method that force a navigation to the same page when is pressed.

Suppose the following sequence:

1 -. User press button 1, I think that the following phases are executed:
Request View --> Apply Request Values --> Proccess Validation --> Update model Values --> Invoke Application (in this phase the actionListener method is executed to load the data from database) --> Render Response (take long time)

2-. Due to a big quantity of data the Render Response take long time and when the lifecycle is in that phase the user press the button 2. I suppose that the following sequence of phases are executed:
Request View --> Apply Request Values -->Invoke Application (Action method that return a navigation case) --> Render Response (Render the page to the user)

My question is, if the first request is in the Render Response phase, what happens with this phase when the second request generated by the Button 2 arrive to the server??? When the second request arrive to the server, JFS automatically cancel or stop the proccesing of the Render Response of the first request ?

Thank you.
9 years ago
JSF
Hi Jeanne Boyarsk, thank you for your response,

but if I change a table in the data base for a view (with the same structure, colums and data type), can I use the same mapping file or need to change it for use a view ? I dont know if for Hibernate is the same use a view or a table. Consider the following task:

1) create a table and a hibernate mapping file for that table
2) develop an application that use this table
3) drop the table in database and create a view that has the same columns and data type, considere an updatable view
4) Can I use the old code with the view ??

Sorry for my english, thank you very much.
Hi,

I have a application that uses several tables, I would like to change one table for a view that contains the same columns and data types, must I to change the application code (hibernate mapping files, daos etc) or hibernate not disting a table from a view. Suppose that the table and the view are identical.

For example, I develop a application that use a table named APP_TABLE. The application is finished and works perfect, but one day I need to change the APP_TABLE for a view that contains the same data and types (maybe with additional columns but not revelavant)

Must I to change the existing application or the application can work with the view without touch any line of previous code??

Regards.
Hi again Siva,

If the bean is using CMT there is no problem because the bean instance no is in a transaction opened before when you call the remove method. (Keep in mind that the previous pseudocode not run with CMT because is using UserTransaction interface for mark the begin and the end of a transaction, you can't use this interface in CMT, if you call ut.begin() you get a IllegalStateException).

The container throw a javax.ejb.RemoveException if you call the remove method in a bean instance that retain a transaction because it has been open before in another method and the transaction has not been finished (with commit or rollback). In CMT, when a method has finished its work the transaction is finished too, the bean instance no mantain the transaction between methods call and for that you can call to the remove method. The remove method can open a new transaction, do it work and finish correctly.

Excuse my mistakes with the english, I hope you could help
Hi Siva,


From ejb core specification, 4.4.4 Restrictions for Transactions:


If a session bean instance is participating in a transaction, it is an error for a client to invoke the
remove method on the session object’s home or component interface object. The container
must detect such an attempt and throw the javax.ejb.RemoveException to the client.
The container should not mark the client’s transaction for rollback, thus allowing the client to
recover.



You can't remove a stateful session bean when the bean is participating in a transaction. Participating in a transaction not means that is on a new transaction opened in @Remove method. Stateful session beans can open a transaction in one method and close the transaction in another, it is posible only with BMT stateful beans, with CMT beans the transaction ends when the method ends and for that the bean no retain the transaction with it instance.

For example, see the next pseudo code, is a stateful session bean BMT that retain the transaction across two client methods calls




If the client do this secuences of call

refMySessionBean.method1()
refMySessionBean.remove() <--- throw a javax.ejb.RemoveException because the bean is participating on a transaction, that not is finished

This secuence must run fine:

refMySessionBean.method1()
refMySessionBean.method2()
refMySessionBean.remove()


Regards
Hi abhay,

You can go to scbcd links and see useful books. For a deeper knowledge take a look Oreilly EJB 3.0, and for entity manager and JPA I have used Apress Pro EJB.3 Java Persistence API.



Hi Mario,

Yes, you can use an Resource Local Entity Manager with BMT demarcation. BMT is a different demarcation of a JTA transaction, in my examples codes I can't use EntityManager.joinTransaction() for join the Application Manager-Resource Local Entity Manager transaction to the current JTA. I don't know why, but in my examples when I use EntityManager.joinTransaction with Resource Local I get a exception. Maybe somebody can help us.

Persistence specification 5.5.2 Resource Local Entity Managers:


An entity manager whose transactions are controlled by the application through the EntityTransaction
API is a resource-local entity manager. A resource-local entity manager transaction is mapped
to a resource transaction over the resource by the persistence provider. Resource-local entity managers
may use server or local resources to connect to the database and are unaware of the presence of JTA
transactions that may or may not be active



I understand that the JTA transaction, in this case with BMT demarcation, is unaware by the EntityManager and due to is a Resource Local it can't join the Resource transaction with the current JTA, for that I see this configuration like independent transactions, once JTA BMT transaction and other a Resource Local Transaction. If you want to rollback the JTA transaction you must use UserTransaction.setRollbackOnly(), if you want to rollback the entity operations you must use EntityTransaction.setRollbackOnly().
Hi Prasad

From the ejb-3.0-specification, point 6.2.2

A persistence unit that is defined at the level of an EJB-JAR,WAR,
or application client jar is scoped to that EJB-JAR, WAR, or application jar respectively and is visible to
the components defined in that jar or war. A persistence unit that is defined at the level of the EAR is
generally visible to all components in the application.



If you try to use a persistence unit from actionBazaar-web.jar, you are getting the persistence unit from lib/actionBazaar-common.jar, because in war file you have not a persistence unit. The web module only has access to ear level persistence unit.

You must follow this rule and forget the class loader in persistence unit scopes. I hope it has helped you
Thanks Davide for your clarification. I am now more confortable wiht the MDB life cycle
Hi,

I have a doubt about how the container process messages simultaneously. Have may differents threads running the same Message Driven Bean Instance ?

For example, if my continer only have a pool of one Message Driven Bean instances, and I have three different clients that send three messages to the same destination, the messages are processed concurrently in the only one intance or the container get the first message, process it, after get the the second process it ... only one thread running per instance.

Thanks.