[Logo] OLD FORUM - Use new one: https://www.CaptainCasa.online/forum
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
How to Determine what paintareaitem was clicked in a dynamic scenario  XML
Forum Index -> Development
Author Message
rspiller

Power User

Joined: 20/04/2012 07:37:01
Messages: 59
Offline

Hi,

i have the following scenario:
Got a "rowdynamiccontent" in which i paste a paintarea with lot of paintareaitems generated by code:
Code:
 ComponentNode bubble = new ComponentNode("t:paintareaitem");
 // here is some bgpaint and bound stuff
 bubble.addAttribute("actionListener", "#{d.VisualizerUI.onClick}");
 bubble.addAttribute("invokeevent", "click");
 

in the managedbean i got the corresponding "onClick-Method" listening to all bubbles created:
Code:
 public void onClick(ActionEvent event) {
     	BaseActionEvent bae = (BaseActionEvent)event;
     	Statusbar.outputMessage(bae.getCommand() + " " + bae.getParams());
 //dunno which Param i acutally get, seems like random Strings on every new click.
     }
 

So now i need to distinguish between the clicked bubbles.
For instance i want to have the "name" or "id" or some kind of unique identifier writen to the Statusbar when clicked on a bubble.
How to do it?

greetings
Ruven
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5555
Offline

Hi,

there are two possibilities:

1. you may assign a reference or a comment to each paintareaitem. In the event processing you then can ask the (BaseActionEvent)event via the methods getSourceReference() or getSourceComment() for the information

2. you assign different action listeners and provide some dynamic sturcture in your bean.

Code:
 e.g. actionListener = #{d.AbcClass.shapes[0].onInvoke}
 
 (the index 0 to be iterated per PAINTAREAITEM instance...)
 
 And in your class:
 
 classAbcClass
 {
     public class Shape
     {
         public void onInvoke(ActionEvent event)
         {
              ...your specific reaction here...
         }
     }
     List<Shape> m_shapes = new ArrayList<Shape>();
     public List<Shape> getShapes() { return m_shapes; }
 }
 


The second way is from my point of view a very nice option if you want also to access additional dynamic information per shape. Then you have one logical object representing each PAINTARAITEM you draw. Maybe you also want to hold some text, background painting etc. in a dynamic way...

Regards, Björn

Björn Müller, CaptainCasa GmbH
rspiller

Power User

Joined: 20/04/2012 07:37:01
Messages: 59
Offline

Hi,

yep! Thanx. Didn't thought about that thing with going deeper in the UI-Class properties.

Next Question: can i get double and single click Events on a paintareaitem?
Currently i set the invokeevent to "click". Then there is the "doubleclick".
Something for both?
Tried to distinguish them with the example from the demo (Buttons) but it only works either single or double.

greetz
Ruven
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5555
Offline

Hi,

there is INVOKEEVENT value "leftanyclick". The number of clicks is a parameter of BaseActionEventInvoke.

Regards, Björn

Björn Müller, CaptainCasa GmbH
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team