on 11-24-2004 3:43 PM
Whenever I want to use a method or attribute of a controller inside a view (<%=controller->attribute%>), the attribute has to be public. I often run into the case that an attribute is only used inside the controller AND on the view, but nowhere else. If the view would be a class, I could add it as a "friend" to the controller class and the view would have access to the attribute although it's private. But since a view is not a class, I guess there is not much I can do except setting the attributes to public, right?
Ironically your view is a class. However it is dynamically generated and has a name something like the following - CL_O2AF3WTE8WB4I3SOYJU1VR1ZWQ5. So I don't think there would be any opportunity to setup a friend relationship.
I'm curious though, I almost never create attributes in my Controller (and when I do they are always private or protected). If I want to share any data with my view, I do that through my Model Class. Perhaps this is just a matter of style, but I was wondering what benefits you see in sharing attributes from the controller to the view?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.