tag:blogger.com,1999:blog-29717104.post115031342644689892..comments2023-06-29T04:59:15.874-06:00Comments on Working with JSF and Facelets: Creating composite controls with JSF and faceletsAnonymoushttp://www.blogger.com/profile/12230997086550680222noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-29717104.post-21279396379977113392009-03-04T20:44:00.000-07:002009-03-04T20:44:00.000-07:00First, please use my new site at http://drewdev.bl...First, please use my new site at <A HREF="http://drewdev.blogspot.com" REL="nofollow">http://drewdev.blogspot.com</A>, I will no longer be keeping this one up to date.<BR/><BR/>If you are having problems with the EL, then you probably do not have the custom component registered correctly. In my example, you will see that I replace the value expression using my buildMethodExpression function.<BR/><BR/>If you do not correctly set up all my steps, then the ValueExpression will not be replaced with the MethodExpression.<BR/><BR/>See the CompositeControlHandler code in the blog.Anonymoushttps://www.blogger.com/profile/12230997086550680222noreply@blogger.comtag:blogger.com,1999:blog-29717104.post-87992884893201415512009-03-04T19:31:00.000-07:002009-03-04T19:31:00.000-07:00Hey Andrew. This is an excellent solution. I'm goi...Hey Andrew. This is an excellent solution. I'm going to use it in my current project. However, there's just one more piece that's not yet resolved.<BR/><BR/>my:test actionListener="#{myBean.doSomething}" <BR/><BR/>In a regular JSF control, the JSF would know that actionListener refers to a method binding and it would not search for a property called doSomething in bean myBean. However, in my:test, this is not apparent and an error is thrown because myBean doesn't have a property called doSomething. How did you fix this issue. Thanks in advance.Tauqueer Alihttps://www.blogger.com/profile/03248441466262053788noreply@blogger.comtag:blogger.com,1999:blog-29717104.post-58518135281871517442007-09-25T00:35:00.000-06:002007-09-25T00:35:00.000-06:00Excellent lecture! Especially the MethodValueExpre...Excellent lecture! Especially the MethodValueExpression solution came in very handy for a simular problem I was facing. It made my modular facelets more reusable as now I can even define dynamic action methods. Thanks a lot!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-29717104.post-4868534992375637502007-06-01T10:00:00.000-06:002007-06-01T10:00:00.000-06:00First make sure you register the sandbox component...First make sure you register the sandbox components correctly using a taglib.xml file. If that is correct and you are still having problems, ask the myfaces user mailing list as it would be a sandbox component problem at that pointAnonymoushttps://www.blogger.com/profile/12230997086550680222noreply@blogger.comtag:blogger.com,1999:blog-29717104.post-82589404821201131652007-06-01T04:31:00.000-06:002007-06-01T04:31:00.000-06:00nice solution!And I am trying to use it. But I tra...nice solution!<BR/><BR/>And I am trying to use it. <BR/><BR/>But I trapped in a problem, all other things go well except sandbox components, no sandbox components can be rendered to browser, any suggestion?<BR/><BR/>Thanks in advance!bwleehttps://www.blogger.com/profile/02903414518336081110noreply@blogger.comtag:blogger.com,1999:blog-29717104.post-11944863852358676482007-01-14T03:54:00.000-07:002007-01-14T03:54:00.000-07:00To hack, or not to hack. I agree that the bean[act...To hack, or not to hack. I agree that the bean[action] solution isn't very JSF-like, and your solution is complete in that sense. But it works, and for us it's not an issue since all our components are Facelets compositions, inherently 'not' black-box since you currently can't define necessary attributes for your composite components other than in your own documentation. So that's the least of our worries :P<br /><br />In defining action vs. value attributes for a composite component, IMO the nicest solution might be to define attributes in the facelets taglib.xml (tld-style) rather than into the composition page itself. Pity that doesn't exist yet :(Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-29717104.post-78272895504496578702007-01-12T09:44:00.000-07:002007-01-12T09:44:00.000-07:00I believe I already commented on that. Richard's s...I believe I already commented on that. Richard's solution is a hack and is not part of the JSF standard way of passing methods. For example:<br /><br /><h:commandButton action="#{myBean.myAction}" /><br /><br />is not written like:<br /><br /><h:commandButton actionBean="#{bean}" action="myAction" /><br /><br />This is ugly and it is obvious that your component is not a JSF component, but instead a facelet source file hack. It is un-elegant IMO and is therefore not an option. <br /><br />JSF components should be a black box, your users should not have to code something in a special way because you decided to use facelets instead of Java to write your component.Anonymoushttps://www.blogger.com/profile/12230997086550680222noreply@blogger.comtag:blogger.com,1999:blog-29717104.post-16382886488103952782007-01-11T22:39:00.000-07:002007-01-11T22:39:00.000-07:00Richard Hightower's solution (linked by stephane) ...Richard Hightower's solution (linked by stephane) is far more elegant if you ask me. The real problem is in delaying execution of an action method. Rather than hack in tag handlers and your own reflective evaluators, why not just use the reflective action="#{backingBean[action]}" EL syntax to accomplish the same thing?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-29717104.post-43640005102105470392007-01-02T08:40:00.000-07:002007-01-02T08:40:00.000-07:00Yes that is an option, but IMO, a horrible hack. "...Yes that is an option, but IMO, a horrible hack. "Normal" JSF allows methods to be put into action and actionListener attributes, why should a facelets composite control be any different?Anonymoushttps://www.blogger.com/profile/12230997086550680222noreply@blogger.comtag:blogger.com,1999:blog-29717104.post-51679983248114139282006-12-29T03:30:00.000-07:002006-12-29T03:30:00.000-07:00Thanks for your answer.
Your solution is too simp...Thanks for your answer.<br /><br />Your solution is too simple for us because we must create too many tags to use it.It's not enough "generics".<br />However we didn't found another solution and we will use your hack.<br /><br />Regards .Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-29717104.post-38722122548630240492006-12-28T14:47:00.000-07:002006-12-28T14:47:00.000-07:00Stephanie,
I am using this solution in a producti...Stephanie,<br /><br />I am using this solution in a production environment. The syntax is not what I would prefer for a facelets component, but it is fine for our own needs. I have been hoping that facelets would adopt this idea, but they haven't yet.<br /><br />You say the solution is too simple for your needs, how so? What functionality is it lacking?Anonymoushttps://www.blogger.com/profile/12230997086550680222noreply@blogger.comtag:blogger.com,1999:blog-29717104.post-69156239085371574822006-12-28T08:26:00.000-07:002006-12-28T08:26:00.000-07:00Hi,
Good solution but as you say in your comment ...Hi,<br /><br />Good solution but as you say in your comment it's a "quick" solution.<br /><br />We try to write our custom component in my company. We have choiced facelets-ajax4jsf-tomahawk-sandbox to write those composite components. But we have had same problems like you. Your solution is good but too simple for our needs.<br /><br />I've searched other solution but I not found. Also I would know if you have improved your solution or ,better, if facelets have solved this problem in another release?<br /><br />Thanks Stephane.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-29717104.post-55889969119910437832006-11-21T09:16:00.000-07:002006-11-21T09:16:00.000-07:00Great articleGreat articleAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-29717104.post-1158807329858832172006-09-20T20:55:00.000-06:002006-09-20T20:55:00.000-06:00excellent article!excellent article!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-29717104.post-1150422686046085262006-06-15T19:51:00.000-06:002006-06-15T19:51:00.000-06:00To be honest, I am hoping that Jacob or another Fa...To be honest, I am hoping that Jacob or another Facelet author picks this up, integrates in into the facelets library and makes it more elegant than my current solution here. This was more of a "quick" solution to get what I needed working.Anonymoushttps://www.blogger.com/profile/12230997086550680222noreply@blogger.com