getter

Edited/updated values in p:dataTable rowEdit are not available in listener method as they are being overwritten by existing data from database

谁说我不能喝 提交于 2019-12-01 21:39:58
I'm editing data with <p:dataTable> row editor as below. <p:dataTable value="#{bean.users}" var="user" editable="true"> <p:ajax event="rowEdit" listener="#{bean.onRowEdit}" /> <p:ajax event="rowEditCancel" listener="#{bean.onRowEditCancel}" /> <p:column> <p:cellEditor> <f:facet name="output"> <h:outputText value="#{user.firstName}" /> </f:facet> <f:facet name="input"> <p:inputText value="#{user.firstName}" /> </f:facet> </p:cellEditor> </p:column> </p:dataTable> The backing bean is implemented as below. private List<User> users; @EJB private UserService userService; public List<User> getUsers(

Simple Scala getter/setter override

不羁岁月 提交于 2019-12-01 15:54:28
Let's say we have a class with a 'name' property: class SuperFoo(var name: String) If I wish to override this, to eg add some locking around the calls: class SubFoo(n: String) extends SuperFoo(n) { val lock = new ReentrantLock override def name(): String = { lock.lock try { super.name } finally { lock.unlock } } override def name_=(arg: String): Unit = { lock.lock try { super.name = arg } finally { lock.unlock } } } The above produces a compilation error: super may be not be used on variable name Any ideas how to correctly implement this? (i.e. override the getter & setter to add locking

Simple Scala getter/setter override

可紊 提交于 2019-12-01 14:59:17
问题 Let's say we have a class with a 'name' property: class SuperFoo(var name: String) If I wish to override this, to eg add some locking around the calls: class SubFoo(n: String) extends SuperFoo(n) { val lock = new ReentrantLock override def name(): String = { lock.lock try { super.name } finally { lock.unlock } } override def name_=(arg: String): Unit = { lock.lock try { super.name = arg } finally { lock.unlock } } } The above produces a compilation error: super may be not be used on variable

Reasons for defining non-const 'get' member functions?

房东的猫 提交于 2019-12-01 14:57:52
I'm working on learning C++ with Stroustrup's (Programming Principles & Practice Using C++) book. In an exercise we define a simple struct: template<typename T> struct S { explicit S(T v):val{v} { }; T& get(); const T& get() const; void set(T v); void read_val(T& v); T& operator=(const T& t); // deep copy assignment private: T val; }; We're then asked to define a const and a non-const member function to get val . I was wondering: Is there any case where it makes sense to have non-const get function that returns val ? It seems much cleaner to me that we can't change the value in such situations

Reasons for defining non-const 'get' member functions?

孤人 提交于 2019-12-01 13:44:36
问题 I'm working on learning C++ with Stroustrup's (Programming Principles & Practice Using C++) book. In an exercise we define a simple struct: template<typename T> struct S { explicit S(T v):val{v} { }; T& get(); const T& get() const; void set(T v); void read_val(T& v); T& operator=(const T& t); // deep copy assignment private: T val; }; We're then asked to define a const and a non-const member function to get val . I was wondering: Is there any case where it makes sense to have non-const get

Setting List items in C# without automatic setter/getter

只愿长相守 提交于 2019-12-01 12:02:29
I'm trying to make a manual setter/getter method in C#, but i'm getting the following error from the "set"-line: Error: The best overloaded method match for 'System.Collections.Generic.ListPackage.Add(Package)' has some invalid arguments private List<Package> packages = new List<Package>(); public List<Package> Packages { set { packages.Add(value); } get { return packages; } } Your code should look like this. private var packages = new List<Package>(); public List<Package> Packages { set { packages = value; } get { return packages; } } If you're trying to use the index getter/setter for some

Getter returning 2d array in C++

旧巷老猫 提交于 2019-12-01 11:07:51
this is my first post on SO, even though i've spent some time already here. I've got here a problem with a function returning a 2d array. I have defined a private 2d int array property int board[6][7] in my Game class, but i don't know how to create a public getter for this property. These are relevant parts of my game.h: #ifndef GAME_H #define GAME_H class Game { public: static int const m_rows = 6; static int const m_cols = 7; Game(); int **getBoard(); private: int m_board[m_rows][m_cols]; }; #endif // GAME_H Now what I would like is something like this in game.cpp (cause I thought array

Getter returning 2d array in C++

无人久伴 提交于 2019-12-01 09:23:47
问题 this is my first post on SO, even though i've spent some time already here. I've got here a problem with a function returning a 2d array. I have defined a private 2d int array property int board[6][7] in my Game class, but i don't know how to create a public getter for this property. These are relevant parts of my game.h: #ifndef GAME_H #define GAME_H class Game { public: static int const m_rows = 6; static int const m_cols = 7; Game(); int **getBoard(); private: int m_board[m_rows][m_cols];

Swift property - getter ivar

落爺英雄遲暮 提交于 2019-12-01 03:20:07
Is there an ivar property we should use in a Swift getter? My code is causing the getter to call the getter until the program crashes: var document: UIDocument? { get { return self.document } set { self.document = newValue useDocument() } } Swift properties do not have the concept of separate, underlying storage like they do in Objective-C. Instead, you'll need to create a second (private) property and use that as the storage: private var _document: UIDocument? var document: UIDocument? { get { return _document } set { _document = newValue useDocument() } } If all you're trying to do is call

Why is BackingBean method called multiple times when requesting facelet?

拜拜、爱过 提交于 2019-12-01 03:12:49
问题 I'm working and learning about JSF + Facelets these days. I have a BackingBean and a Facelet xHTML page. When I request the facelet-page (only one time) the backing-bean-method is called multiple times. What could be the reason for this? I can't see anything special. Thanks in advance. Here is the facelet: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3