[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 
Method declare on other class wont fire.  XML
Forum Index -> Development
Author Message
vadingding

Power User
[Avatar]

Joined: 14/07/2017 13:26:37
Messages: 145
Offline

Hi captain,

Im having trouble on firing a method attached on a button.

I created a new class using my IDE (not with the editor). Then I created the method there and set it to a button node under that class too.

The way I did it:
BUTTONNode btn = new BUTTONode();
btn.setActionListener("#{d.AnotherClass.method}");

I runned it but it didnt work. Am I missing something? Or is it possible?

Thanks!
CaptainCasa

Power User
[Avatar]

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

Hi,

there are certain options...:

If the class is defined outside the "managedbeans"-package (the one in which the Dispatcher.class resides) then this package must be registered in disaptcherinfo.xml so that the framework can find your class. Search for "dispatcherinfo.xml" in the Developers' Guide for more info, please.

Your class must either have a constructor without parameters, or the only parameter of the constructot may be IWorkpageDispatcher.

Your class and your method must be public.

Your method must use ActionEvent from JSF package as parameter, and not the one which may be proposed by the IDE from java-awt or from java-fx...


I hope, one of the options will be the one to solve your problem. Otherwise please attach your code. Thanks!

Regards, Björn

Björn Müller, CaptainCasa GmbH
vadingding

Power User
[Avatar]

Joined: 14/07/2017 13:26:37
Messages: 145
Offline

Hi Captain,

My class is defined under managedbeans package.
My class have a constructor with a number if parameters.
My method uses ActionEven from JSF.

Here is my class:

Code:
 public class PageClass {
 	private FIXGRIDListBinding<MyRow> rowBind;
 	private ROWDYNAMICCONTENTBinding dynamicRow;
 	private ROWDYNAMICCONTENTBinding dynamicRibbonRow;
 	private String pageID;
 	
 	public PageClass(FIXGRIDListBinding<MyRow> rowBind, ROWDYNAMICCONTENTBinding dynamicRow, ROWDYNAMICCONTENTBinding dynamicRibbonRow, String pageID) {
 		this.rowBind = rowBind;
 		this.dynamicRow = dynamicRow;
 		this.dynamicRibbonRow = dynamicRibbonRow;
 		this.pageID = pageID;
 	}
 }
 


Here is the button that I want to assign the method.

Code:
 BUTTONNode btn = new BUTTONNode();
 btn.setHeight(22);
 btn.setActionListener("#{d.PageClass.onNew}");
 btn.setContentareafilled(false);
 btn.setText(btnCaption);
 


Here is my method:

Code:
 public void onNew(javax.faces.event.ActionEvent event) {
 	PageClass.MyRow row = new PageClass.MyRow();
 	row.setStaffCode("x");
 	row.setStaffName("x");
         row.setStaffUserGroup("x");
 	m_rowBind.getItems().add(row);
 	m_rowBind.deselectCurrentSelection();
 	m_rowBind.selectAndFocusItem(row);
 }
 
CaptainCasa

Power User
[Avatar]

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

Hi,

then it is the constructor: please use a constructor without parameters and you will see that your class will start to get "alive" in the layout editor.

Situation is:

In the edting environment the class must be instance-able just from its expression "#{d.PageClass. ...}" - so there must be some default way to create the instance. This is by constructor withtout parameters.

So add...
Code:
 public PageClass()
 { 
     this.rowBind = new FIXGRIDListBindin = new ....;
     this.dynamicRow = new ...;
     etc.
 }
 


Later on if the class may be used within another PageBean-class you may use your own constructor - but the Layout Editor just needs to work with an object instance.

Regards, Björn

PS: In general, looking onto your constructor of PageClass: I am not sure if it's a totally good idea to pass inner details from the class from outside through the constructor? ;-) - But, maybe this is some special, generic class on your side?

Björn Müller, CaptainCasa GmbH
vadingding

Power User
[Avatar]

Joined: 14/07/2017 13:26:37
Messages: 145
Offline

Hi Captain,

I followed you instructions, and it works! But I have another question if you dont mind..

What if I will declare my ROWDYNAMICCONTENTBinding under PageClass? Not on the class that created by the editor?

Then I will set the contentBinding of the rowdynamiccomponent onto that ROWDYNAMICCONTENTBinding under PageClass?

Would it be possible? Will the system able to see my declaration?

Thanks..
CaptainCasa

Power User
[Avatar]

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

...you have to pay attention to the expressions, that's that you have to keep in mind:

The typical situation is:

Page = whatever.jsp
PageBean class = WhateverUI.class

In the page you reference #{d.WhateverUI.*}

So also in the dynamic content you reference #{d.WhateverUI.*}. The best way to build expressions is the pbx()-method, e.g. if you defien pbx("onAction") then the system will automatically make "#{d.WhateverUI.onAction}" out of it.

It is not allowed (or better say: useful) to reference other classes in the whatever.jsp bean! This has to do with dynamic expression adaptation during runtime. At runtime the "#{WhateverUI." of the expression is actually replaced by the location where the corresponding page bean is located.

Let's assume you have an outer page / page bean "outer.jsp" / "OuterUI.class", this has an ROWPAGEBEANIN)CLUDE to "#{d.OuterUI.innerBean}". And let's assume that the inner bean is of class "WhateverUI.class":

So in the inner page bean all expressions are on the fly adapted from "#{d.WhateverUI.*}" to "#{d.OuterUI.innerBean.*}" so that the expression ponits to the right object constellation.


In principal you do not have to know about these inner things because if you follow the principle "one page => one page bean" then everything happens without you knowing about. - But it also shows that the correct naming/handling of expressions when using dynamic content is important.


I hope this helps, and does not confuse...

Regards, Björn

Björn Müller, CaptainCasa GmbH
vadingding

Power User
[Avatar]

Joined: 14/07/2017 13:26:37
Messages: 145
Offline

Is it needed to extend MyClass to PageBean?
Because MyClass is created via IDE, then I want to declare some ROWDYNAMICCONTENT in this class and bind its expression to another class that is created via CaptainCasa editor, so that I will not need to pass those inner details via MyClass Constructor, and in that way MyClass Constructor doesnt need parameters no more.

Is this possible?
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team