composition

When using <ui:composition> templating, where should I declare the <f:metadata>?

ⅰ亾dé卋堺 提交于 2019-11-26 04:50:50
I have made a lot of progress in converting my JSF applications to book-markable pages, but I am wondering if I am doing it the right way. One question is that is there a best-practice location for the f:metadata tags? My typical Facelets client page looks like this: <ui:composition template="./pattern.xhtml"> <ui:define name="content"> <f:metadata> <f:viewParam name="userId" value="#{bean.userId}" /> <f:viewParam name="startRecord" value="#{bean.startRecord}" /> <f:viewParam name="pageSize" value="#{bean.pageSize}" /> <f:viewParam name="sort" value="#{bean.sort}" /> </f:metadata> <h1>Data

Concrete example showing that monads are not closed under composition (with proof)?

*爱你&永不变心* 提交于 2019-11-26 04:36:54
问题 It is well-known that applicative functors are closed under composition but monads are not. However, I have been having trouble finding a concrete counterexample showing that monads do not always compose. This answer gives [String -> a] as an example of a non-monad. After playing around with it for a bit, I believe it intuitively, but that answer just says \"join cannot be implemented\" without really giving any justification. I would like something more formal. Of course there are lots of

C++ implicit copy constructor for a class that contains other objects

我是研究僧i 提交于 2019-11-26 02:48:52
问题 I know that the compiler sometimes provides a default copy constructor if you don\'t implement yourself. I am confused about what exactly this constructor does. If I have a class that contains other objects, none of which have a declared copy constructor, what will the behavior be? For example, a class like this: class Foo { Bar bar; }; class Bar { int i; Baz baz; }; class Baz { int j; }; Now if I do this: Foo f1; Foo f2(f1); What will the default copy constructor do? Will the compiler

When using <ui:composition> templating, where should I declare the <f:metadata>?

时光怂恿深爱的人放手 提交于 2019-11-26 01:53:50
问题 I have made a lot of progress in converting my JSF applications to book-markable pages, but I am wondering if I am doing it the right way. One question is that is there a best-practice location for the f:metadata tags? My typical Facelets client page looks like this: <ui:composition template=\"./pattern.xhtml\"> <ui:define name=\"content\"> <f:metadata> <f:viewParam name=\"userId\" value=\"#{bean.userId}\" /> <f:viewParam name=\"startRecord\" value=\"#{bean.startRecord}\" /> <f:viewParam name

Java - Method name collision in interface implementation

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 00:19:26
问题 If I have two interfaces , both quite different in their purposes , but with same method signature , how do I make a class implement both without being forced to write a single method that serves for the both the interfaces and writing some convoluted logic in the method implementation that checks for which type of object the call is being made and invoke proper code ? In C# , this is overcome by what is called as explicit interface implementation. Is there any equivalent way in Java ? 回答1:

Extends JFrame vs. creating it inside the program

前提是你 提交于 2019-11-25 23:06:44
问题 When making an application using Swing, I\'ve seen people do one of the two things to create a JFrame. Which is a better approach and why? I\'m a beginner at Java and programming. My only source of learning is books, YouTube and Stack Overflow. import {imports}; public class GuiApp1 { public static void main(String[] args) { new GuiApp1(); } public GuiApp1() { JFrame guiFrame = new JFrame(); guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); guiFrame.setTitle(\"Example GUI\"); guiFrame

Prefer composition over inheritance?

六眼飞鱼酱① 提交于 2019-11-25 22:51:57
问题 Why prefer composition over inheritance? What trade-offs are there for each approach? When should you choose inheritance over composition? 回答1: Prefer composition over inheritance as it is more malleable / easy to modify later, but do not use a compose-always approach. With composition, it's easy to change behavior on the fly with Dependency Injection / Setters. Inheritance is more rigid as most languages do not allow you to derive from more than one type. So the goose is more or less cooked

What is the difference between association, aggregation and composition?

天大地大妈咪最大 提交于 2019-11-25 22:34:48
问题 What is the difference between association, aggregation, and composition? Please explain in terms of implementation. 回答1: For two objects, Foo and Bar the relationships can be defined Association - I have a relationship with an object. Foo uses Bar public class Foo { void Baz(Bar bar) { } }; Composition - I own an object and I am responsible for its lifetime. When Foo dies, so does Bar public class Foo { private Bar bar = new Bar(); } Aggregation - I have an object which I've borrowed from

Difference between Inheritance and Composition

♀尐吖头ヾ 提交于 2019-11-25 22:33:42
问题 Are Composition and Inheritance the same? If I want to implement the composition pattern, how can I do that in Java? 回答1: They are absolutely different. Inheritance is an "is-a" relationship. Composition is a "has-a" . You do composition by having an instance of another class C as a field of your class, instead of extending C . A good example where composition would've been a lot better than inheritance is java.util.Stack , which currently extends java.util.Vector . This is now considered a