voyent
ContextActionEvent, wrong contextvalue  XML
Forum Index -> General Help
Author Message
andreiij

Joined: 15/Feb/2009 00:00:00
Messages: 35
Offline


I'm using a dynamic MenuPopup for a panelGroup, together with a dispalyListener.

The panelGroup has the contextValue attribute specified.
The panelGroup is also child of two <ui:repeat> loops

In the actionListener for the menuItems I can retrive this contextValue

Code:
 
 public void someAction(ActionEvent event) {
         ContextActionEvent ctxEvent = (ContextActionEvent) event;
         Object o = ctxEvent.getContextValue;
 


However, this context value (that is Object o) is always "one click behind" (ie, giving the object that was previous clicked, starting with null)

Is this a icefaces bug or relating to my repeat tags?

I'm able to workaround by saving the the correct object via an attribute to the menuPopup which i can get in the displayListener:

Code:
   <ice:menuPopup displayListener="#{bean.displayListener}"
         binding="#{bean.menuPopup}" id="menuContext"
         style="position:absolute; top:-140px; left:-310px; z-index:3000;">
         <f:attribute name="myContextAttribute" value="#{currentRepeatObject}"/>
     </ice:menuPopup>
 


and in displayListener

Code:
  public void displayListener(DisplayEvent event) {
 
         MenuPopup popup = (MenuPopup) event.getComponent();
   
      Object contextObj =  event
                 .getComponent().getAttributes().get("myContextAttribute");
 



/Andreiij
pandoo


Joined: 06/Feb/2008 00:00:00
Messages: 69
Offline


Hi there,

I tried to reproduce your problem but I couldn't find that strange "one click behind" behaviour.

VIEW CODE:
Code:
 <ui:repeat value="#{forum14252.users}" var="aUserObject">
   <ice:panelGroup menuPopup="menuPopup" contextValue="#{aUserObject}">
     <ice:outputText value="#{aUserObject.userName}" />
   </ice:panelGroup>
   <ice:menuPopup id="menuPopup">
     <ice:menuItem value="Actions">
       <ice:menuItem actionListener="#{forum14252.actionListener}" value="Print: #{aUserObject.userName}">
       </ice:menuItem>
     </ice:menuItem>
   </ice:menuPopup>
 </ui:repeat>
 



BEAN CODE:
Code:
 public void actionListener(ActionEvent event) {
   if (event instanceof ContextActionEvent) {
 	ContextActionEvent ce = (ContextActionEvent) event;
 	UserObject obj = (UserObject) ce.getContextValue();
 	System.out.println(obj.getUserName());
   }
 }
 


Is this code snippet similar to the one you had before your workaround?

Thanks for your help!
andreiij

Joined: 15/Feb/2009 00:00:00
Messages: 35
Offline


Im using a binding for the menuPopup, if that could possible change anything
pandoo


Joined: 06/Feb/2008 00:00:00
Messages: 69
Offline


...using the binding attribute on the menuPopup:
VIEW CODE:
Code:
 <ice:menuPopup id="menuPopup" binding="#{forum14252.menuPopup}">

BEAN CODE:
Code:
 public class Forum14252 {
 	private MenuPopup menuPopup;
         //....
 }
 

... I still can't get that behaviour. If you don't mind, you could try to use my code snippet and see if it works in your application.



andreiij

Joined: 15/Feb/2009 00:00:00
Messages: 35
Offline


Ok, thanks for your efforts (so far) !
felix41382

Joined: 18/Oct/2007 00:00:00
Messages: 21
Offline


Hey Andreiij,

same problem over here! I am using a dataTable and menuPopup, so it's not the ui:repeat! Did you ever find a solution?
andreiij

Joined: 15/Feb/2009 00:00:00
Messages: 35
Offline


My solution was a workaround: To skip the contextValue and use a field in a bean set from the displayListener.

Don't know if it has to do with phases and DOM-updates which im still (frankly...) trying to grasp.
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team