How to handle p:ajax event

UI Components for JSF
alekss
Posts: 10
Joined: 05 Feb 2012, 22:27

05 Feb 2012, 22:32

Please explain how to handle ajax event in spring web flow.
For example if we have page code
<h:commandLink id="nextPageLink" value="More Results" action="next"/>
so we can use "next" in flow definition
<transition on="next">

But what about such evebts like
<p:accordionPanel>
<p:ajax event="tabChange" listener="#{myBean.onTabChange}" />

By primefaces tutorial it can be handled in MyBean in such way:

public void onChange(TabChangeEvent event)
{
Tab activeTab = event.getTab();
}

But how this event may be handled in Spring context?

Thank you

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

06 Feb 2012, 06:58

If you have good understanding of spring webflow and Primefaces components (accordionPanel event="tabChange"), then it is best to merge the two concepts and see how you can make it work.

1. Try to get accordionPanel tabChange to meet your requirements without spring webflow.

2. Afterwards, try to merge or make use of spring webflow benefits.

3. You may want to consider p:wizard. From what I have read here in community forum, p:wizard is similar to p:tabView (and p:tabView and p:accordionPanel are similar). p:wizard has a way of 'flowing' through the tabchanges. I am writing based on assumption, personal experience of what a 'wizard' is/does, and what i have read here, when community users are discussing p:wizard.

I am not a user of spring webflow, so I cannot advise any further. Below, you will see my test/development environment details. :)
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

alekss
Posts: 10
Joined: 05 Feb 2012, 22:27

08 Feb 2012, 10:30

cannot save reply :(

alekss
Posts: 10
Joined: 05 Feb 2012, 22:27

08 Feb 2012, 10:41

Excuse me, but I cannot save my reply here.
Mistake appears
General Error
SQL ERROR [ mysqli ]

Incorrect string value: '\xE2\x80\x9Dtab...' for column 'post_text' at row 1 [1366]

An SQL error occurred while fetching this page. Please contact the Board Administrator if this problem persists.

alekss
Posts: 10
Joined: 05 Feb 2012, 22:27

08 Feb 2012, 10:42

I write my answer and question there
http://forum.springsource.org/newreply. ... &noquote=1

Could you answer?

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

08 Feb 2012, 18:13

alekss wrote:Excuse me, but I cannot save my reply here.
Mistake appears
General Error
SQL ERROR [ mysqli ]

Incorrect string value: '\xE2\x80\x9Dtab...' for column 'post_text' at row 1 [1366]

An SQL error occurred while fetching this page. Please contact the Board Administrator if this problem persists.
Because you copy/pasted a single quote character or a escaped character. I have seen that error message and i had to remove escaped characters and/or single quote characters from my post/response.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

08 Feb 2012, 18:15

alekss wrote:I write my answer and question there
http://forum.springsource.org/newreply. ... &noquote=1

Could you answer?
It would not show me your question there, it said the following:
You are not logged in. Fill in the form at the bottom of this page and try again.
You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
Sorry, i'm not a sping (framework) user and I only contribute to this community. :)
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

alekss
Posts: 10
Joined: 05 Feb 2012, 22:27

08 Feb 2012, 18:52

Thank you. I corrected this mistake.
So the question is -

I have in my page
Code:
<p:tabView id="tabView" var="category" value="#{showcaseBean.categories}">
When I'm clicking every tab the next tab with related goods to this category should appear.
So I have to catch
Code:
<p:ajax event="tabChange" listener="#{showcaseBean.onChange}" />
in my showcaseBean and fetch the related goods from database like
Code:
ShowcaseService.getGoodsByCategory(Category category) {}
This ShowcaseService can work with database only through flow.xml file (because transaction is bound to flow).
So I cannot make something like
Code:
(inside ShowcaseBean)
ShowcaseService showcaseService = new ShowcaseService();
showcaseService.getGoodsByCategory(Category category)
Instead of it I have to reflect this fetching in flow.xml like
Code:
<transition on="changeTab">
<evaluate expression="showcaseService.getGoodsByCategory(showcaseBean.selectedCategory)" />
</transition>
But examples (that I have seen) show the handling only JSF action (in flow.xml ) like
Code:
<transition on="cancelBooking">
<evaluate expression="bookingService.cancelBooking(bookings.selectedRow)" />
</transition>
where cancelBooking taken from
Code:
<p:commandButton id="cancel" value="Cancel" action="cancelBooking"/>
So how can I reflect "tabChange" event
Code:
<p:ajax event="tabChange" listener="#{showcaseBean.onChange}" />
in flow.xml to invoke method getGoodsByCategory of ShowcaseService?

There are different events - not only <p:button action ="MyAction"/>
For example valueChangeListener for selectOneMenu.
How I can catch such event in spring web flow?

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

08 Feb 2012, 18:57

alekss wrote:I have in my page

Code: Select all

<p:tabView id="tabView" var="category" value="#{showcaseBean.categories}">
When I'm clicking every tab the next tab with related goods to this category should appear.
So I have to catch

Code: Select all

<p:ajax event="tabChange" listener="#{showcaseBean.onChange}" />
in my showcaseBean and fetch the related goods from database like

Code: Select all

ShowcaseService.getGoodsByCategory(Category category) {}
This ShowcaseService can work with database only through flow.xml file (because transaction is bound to flow).
So I cannot make something like
(inside ShowcaseBean)

Code: Select all

   ShowcaseService showcaseService = new ShowcaseService(); 
   showcaseService.getGoodsByCategory(Category category)
Instead of it I have to reflect this fetching in flow.xml like

Code: Select all

<transition on="changeTab">
  <evaluate expression="showcaseService.getGoodsByCategory(showcaseBean.selectedCategory)" />
</transition>
But examples (that I have seen) show the handling only JSF action (in flow.xml ) like

Code: Select all

<transition on="cancelBooking">
			      <evaluate expression="bookingService.cancelBooking(bookings.selectedRow)" />
		          </transition>
where cancelBooking taken from

Code: Select all

 <p:commandButton id="cancel" value="Cancel" action="cancelBooking"/>
So how can I reflect "tabChange" event

Code: Select all

<p:ajax event="tabChange" listener="#{showcaseBean.onChange}" />
in flow.xml to invoke method getGoodsByCategory of ShowcaseService?
I quoted your response and added code tags via code button, since it is easier for us all to read. i hope you learn to use the code tag via code button when responding with code. I'll review code after submitting this post.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

08 Feb 2012, 19:03

1. Hmmm, okay, i just saw earlier posts, and I see you are using spring webflow. I am not a spring webflow user, so I can only reply with some suggested searches.

2. see following, and search community forum via google like I did. I responded to a similar topic; your tabview tabchange, seems similar to the implementation of p:wizard (which is similar to tabview w/ tabChange), and there has been discussion of this requirement/issue by other spring webflow users.

forum.primefaces.org tabview tabchange flow.xml
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 28 guests