Author |
Message |
08/01/2020 08:24:13
|
jschmidt
Active
Joined: 11/11/2019 15:46:33
Messages: 19
Offline
|
Can I access multiple beans in one JSP file?
<t:label text="#{d.one.name}" />
<t:label text="#{d.two.name}" />
<t:label text="#{d.three.name}" />
|
Regards, Julian |
|
|
08/01/2020 10:49:03
|
CaptainCasa
Power User
Joined: 21/11/2007 12:23:06
Messages: 5535
Offline
|
This is NOT recommended and is only "allowed" for special situations.
So the 99,99% answer to your question is: "No!"
(The problem is the instance management on server side so that each expression reaches its correct instance.)
Regards, Björn
|
Björn Müller, CaptainCasa GmbH |
|
|
08/01/2020 11:56:13
|
jschmidt
Active
Joined: 11/11/2019 15:46:33
Messages: 19
Offline
|
Okay, I would argue I'm the 0,01% now.
In my case I have a page containing three subpages with rowpagebeanbinding. I want each subpage to know if a checkbox on the container page is set.
If I'm not able to reference other Beans from inside my JSP file, I will have to write a method in all Beans that basically do nothing but fetch the checkbox value from the container Bean. That leads to high code duplication. Hence the question.
So am I understanding you correctly that there is no other way than to write the exact same getters and setters in all three subpage Beans along with the member definitions?
Or is there an alternative to provide information across multiple JSP files?
Regards, Julian
|
Regards, Julian |
|
|
08/01/2020 12:07:34
|
CaptainCasa
Power User
Joined: 21/11/2007 12:23:06
Messages: 5535
Offline
|
This is not the 0,01% case! ;-)
Of course you can inherit the sub-beans from one central "child-area"-class so that the code is not multiplied.
Or, you may do reference in the way: #{d.Xxxx.parent.checked} and thus can make available more attributes of the parent without explicit coding.
Regards, Björn
PS: some more explanation on the philosophy behind:
THe outer pageBean is "Aaa.java", the inner pageBean is "Bbb.java", so expressions are "#{d.Aaa.*}" in the outer, and "#{d.Bbb,*}" in the inner page.
Now Aaa contains Bbb as ROWPAGEBEANINCLUDE. So in Aaa ther is a property "content" which holds a Bbb instance:
This means...:
#{d.Aaa.content} is the expression for the include.
As consequence all expression in "Bbb" are converted on the fly from "#{d.Bbb.*}" to "#{d.Aaa.content.*}" - because the original access to the Bbb properties goes throug the Aaa.content property.
So there is a replacement of expressions: all the expressions for the page Bbb are converted accodingly. That's the reason why each pageBean knows its page (Bbb.jsp) and its representation in the page (#{d.Bbb}). If now a page bean has several expression to several classes then the expression rightsizing cannot be executed anymore successfully.
|
Björn Müller, CaptainCasa GmbH |
|
|
|