I have a fragment with a table.
the value of this table comes from a list in the bean.
I need to fill the list when the fragment is loaded.
I was trying to do that as I saw here:
https://kr.forums.oracle.com/forums/thread.jspa?threadID=2386966
but I see that it's filling the list on load and then the constructor of the bean is called again,
so the list get a new instance and in fact its empty again.
Do you know why it happens?
Or is there any other way to fill a list in the bean when the fragment is loaded?
Thanks!
You need to change the scope of your bean.
I suggest trying the 'view scope' first.
You can have the default entry point to your taskflow be a method call that initialize a list in a pageflowscope managed bean. Then you should be able to refer to that list in all the pages in your flow.
Related
How to get the current object id in Admin::configureListFields?
$this->getSubject() returns null
Thank you
Since there are many objects in a list, your question makes no sense. I'll go ahead and assume you are in a child admin. If this is the case, I think you are looking for $this->getParent()->getSubject()->getId()
Based on the way you've phrased your question I assume you ran into the same issue as I did.
My assumption is thus: You are looking to use configureListFields to manipulate the content of the rows of the list / the "current" element.
As greg0rie pointed out - there is a misconception here in that there is no "current" element.
Specifically - configureListFields s called before the list is iterated for output so no current element exists.
Furthermore, as far as I can tell there is no method we can overwrite that is called specifically when the list is iterated over.
Therefore, what I ended up doing is the following:
First overwrite the twig template of whatever you're wanting to change in the list.
Then create a Twig extension function and pass in the "admin" and "object" properties that should be available at template level at this point:
{{ myTwigFunction(admin, object) }}
admin is the instance of the sonata admin rendering the list.
object is the current template.
Therefore, you now have access to the current entity object as well as the sonata admin that's handling it.
Personally I then passed this into a service to generate the changes I wanted to make.
Iam getting my data with help of the Angular's $resource service as array. Each element of that array is an Resource-Object. So i can use methods like $save and $update of these Objects. In a view i represent my array with the help of the ng-repeat directive like:
<div ng-repeat="appointment in object.appointments" ng-click="editAppointment(appointment)">
And here i get in trouble. The appointment-Object i get in the editAppointment-Method is a simple Object. No Resource Object anymore. So i cant use the helpfull methods like i mentioned above.
$scope.editAppointment= function(appointment){
console.log(appointment); // > Object
console.log(object.appointments); // > Array of Resource
}
Have somebody noticed that problem too? May its a bug, but i cant imagine that.
Assuming your resource class is called Appointment, you should just be able to do:
$scope.editAppointment= function(appointment){
new Appointment(appointment).save();
}
Presumably your Appointment resource looks something like the following (i.e. it correctly maps some sort of id property from existing objects to the URL parameters):
var Appointment = $resource('/appointment/:appointmentId', {appointmentId:'#id'});
This would be the case if your appointment objects (i.e. the underlying JSON objects handled by your API) have an ID property called id. If it's called something else (or if there are multiple path variables in your URL) you'll just need to change the second argument to map all of the properties of the objects being saved (the values starting with '#') to the URL path variables (the things starting with ':' in your URL).
See where they save a new card in the credit card example here: http://docs.angularjs.org/api/ngResource.$resource. The fact that they're dealing with a totally new object and that you're trying to save an existing one is irrelevant. Angular doesn't know the difference.
I have seen this bunch of code in a tutorial:
var searchTerm = this.$('#searchTerm').val().trim();
I would like to understand the utility of the this. in front of the selector, it's the first time i see that.
In a Backbone.View, this.$ gives a scoped version of jQuery. It is in fact equivalent to using this.$el.find which is in turn equivalent to using $(this.el).find.
Anyhow, the reason it is a good idea to use it is that it will only access html elements from within the view's element/rendered template. Thus, you don't have to worry about the rest of the html page and you will always select the element you expect to.
Imagine that you have a view that spawns sub-views and that each of these have an editable field. If you don't use the scoped version of jQuery to get the right editable field, you will have to give a unique id to each of these html elements to make sure you will select the right one when retrieving it's content. On the other hand, if you use the scoped version, you will just have to give this editable field a class attribute and selecting this class will give you a unique element, the right one.
This is the same query as this.$el.find('#searchTerm').val().trim();
You haven't given any context to that code, but assuming it's a method inside a View, this refers to the View object.
this.$ is a shortcut to access jQuery from the View object, and is equivalent to the method this.$el.find.
I am new to Cakephp and indeed OOP, so forgive me if i haven't fully grasped the MVC concept yet. I have search a lot but cannot find an answer - perhaps my way of working below is not correct. I hope you can help.
I am building a site which will have many elements relating to their tables and data. I intend to use a view to pick and choose the relevant elements and any parameters needed.
For example, the homepage of my site will have two elements - a latestusers element and a latestscores element. I am trying to use a view not related to either the users or scores models/controllers, stored in 'other/index.ctp'.
I have tried using set() to pass a variable from the users controller (latestusers action) into the other/index.ctp view, but the viewVars remain empty. Could this be due to scope of the variable (i think it is fine for a view in the users folder, i.e. a view specific to the users controller).
I could achieve what i want to do by using global variables, but i think this is missing the point of MVC/OOP. Would be grateful for any suggestions.
I can include code if need be - it is fairly basic at this stage - but i feel my problem lies with how i am going about things, not the code itself.
Cheers,
James
Yes, the issue is with the scope. If you're going to use variables in the element you'll need to pass them in from your view. So the flow would look something like this
Controller $this->set()s the variable into your current view/layout
Your view/layout calls $this->element with the current element path.
Your element uses those variables.
In number 2 you need to pass your variables as an array of data. This section on the cookbook gives more information : http://book.cakephp.org/view/1081/Elements
<?php echo$this->element('helpbox',
array("helptext" => "Oh, this text is very helpful."));?>
Note - I didn't understand part of the question. Just want to make sure you are passing data to the correct view. You should not be calling the view of another controller in your active controller.
Your other/index.ctp should be an element and that element should be called from your layout.
i'm very new to sencha.i have a bit problem in accessing the data from framework..
what i planned is to access the attribute "selectedIndex" from the class Ext.Picker.Slot
so that i can place it the index.js file and loop the "selectedIndex" attribute so that i can create a rotating effect to my list , i'm trying to dynamically change the value of "selectedIndex" so that my list seems to be rotating so please do help me........
Thankyou,
........
Ext.Picker is not an extjs class. You should provide more info so I can help you. In any way there must be a method which puts selectedIndex to desired value. Js don't have properties like in other OOP languages. It's just a variable. Changing value of it don't do any "action". So, there must be method which do the "action" and sets selectedIndex.