Flex Mobile Project: List - list

I am developing a mobile application in which I want to use a list which contains 400 rows. I got data from Sqlite database. When I run the application and click the button for the list, the list view is loading so slowly and takes about 45 seconds. I also tried getting data from an arraycollection inside the application but I had same problem. Is this normal? Any idea or advice for this issue?
sqlStat.text="SELECT City FROM Cities";
sqlStat.execute();
dataArray=sqlStat.getResult().data;
appModel=AppModel.getInstance();
if(appModel.cities == null)
{
appModel.cities = new ArrayCollection();
var obj:Object;
for( var i:int=0; i<dataArray.length; i++ )
{
obj = new Object();
obj.Name = dataArray[i].City
appModel.cities.addItem(obj);
}
myList.dataProvider=appModel.cities;
}

The OP wrote:
I solved my problem. ListForm component causes renderer problem. I used List component instead of that and created arrayCollection dataprovider for my list inside my class. It works faster than previous.

Related

data-dialog created dynamically

I'm using polymer 1.0.
I'm trying to open a with on a clic on an element created dynamically with template repeat.
Here is the code :
<paper-button
data-dialog="modal"
on-click="dialogClick">
Click
</paper-button>
and the script (from doc) :
dialogClick: function(e) {
var button = e.target;
while (!button.hasAttribute('data-dialog') && button !== document.body) {
button = button.parentElement;
}
if (!button.hasAttribute('data-dialog')) {
return;
}
var id = button.getAttribute('data-dialog');
var dialog = document.getElementById(id);
alert(dialog);
if (dialog) {
dialog.open();
}
}
This work only if the value of data-dialog is simple text. If I want to change it by data-dialog="{{item.dialogName}}" for instance, it doesn't work. It is not found by the while loop and exit with the if. in the source code of the page, there is no data-dialog in the paper-button.
Any idea ?
I've ran into a similar problem when using data attributes on custom elements. You might want to subscribe to this polymer issue.
As a workaround, place the data attribute in a standard element that is a parent of the button and search for that one instead.
Also, you might want to consider using var button = Polymer.dom(e).localTarget instead of directly accessing e.target, since the later will give you an element deeper in the dom tree under shady dom.

Sitecore, render Item in code with personalization in mvc

My terminology might be slightly off as I am new to Sitecore mvc. I am trying to hardcode a view rendering with a hard coded datasource (I have to do it this way for other requirements) This view rendering has placeholders that are dynamically set and then personalized.
How can I trigger the ViewRendering on an item?
I've tried ItemRendering, but it doesn't seem to be picking up the stuff set up in the PageEditor.
* To be clear, the helpful posts below have the rendering working, but we do not seem to be getting the personalized datasources. *
I believe this is what you're after:
Item item = /* think you already have this */;
// Setup
var rendering = new Sitecore.Mvc.Presentation.Rendering {
RenderingType = "Item",
Renderer = new Sitecore.Mvc.Presentation.ItemRenderer.ItemRenderer {
Item = item
}
};
rendering["DataSource"] = item.ID.ToString();
// Execution
var writer = new System.IO.StringWriter();
var args = new Sitecore.Mvc.Pipelines.Response.RenderRendering(rendering, writer);
Sitecore.Mvc.Pipelines.PipelineService.Get().RunPipeline("mvc.renderRendering", args);
// Your result:
var html = writer.ToString();
You can statically bind a View Rendering using the Rendering() method of the Sitecore HTML Helper. This also works for Controller Renderings using the same method.
#Html.Sitecore().Rendering("<rendering item id>")
This method accepts an anonymous object for passing in parameters, such as the Datasource and caching options.
#Html.Sitecore().Rendering("<rendering item id>", new { DataSource = "<datasource item id>", Cacheable = true, Cache_VaryByData = true })
In your view rendering, I am assuming you have a placeholder defined along with the appropriate placeholder settings in Sitecore (If not, feel free to comment with more detail and I will update my answer).
#Html.Sitecore().Placeholder("my-placeholder")
In this case, "my-placeholder" will be handled like any other placeholder, so you will be able to add and personalize components within it from the Page Editor.

Android - List app icons in list and run selected

Im developing an Android app in eclipse.
I have a list showing the applications installed, the list is this:
//Listar apps instaladas
final ListView list1 = (ListView) findViewById(R.id.list1);
ArrayList results = new ArrayList();
PackageManager pm = this.getPackageManager();
Intent inte = new Intent(Intent.ACTION_MAIN, null);
inte.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> list = pm.queryIntentActivities(inte, PackageManager.PERMISSION_GRANTED);
for (ResolveInfo rInfo : list) {
results.add(rInfo.activityInfo.applicationInfo.loadLabel(pm).toString());
}
list1.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, results));
My questions are:
How I can do that instead of showing the icons name? if I do it
results.add(rInfo.activityInfo.applicationInfo.loadLabel(pm).toString());
show me "android.graphics.drawable # name of the application"
And how I can do to run the application by clicking on the list? I tried several attempts, but I make the application error.
Thanks!
results.add(rInfo.activityInfo.applicationInfo.loadLabel(pm).toString());
with this line of code I assume you're loading the label of the application, so perhaps you should try loadName or something, check what you can pick there anyway since I haven't done this myself before.
And which error do you get when you click the list? this would be helpful too :)

How do I utilize the save event in a Sitecore custom Item Editor?

I am creating a custom item editor, and am using the following blog post as a reference for responding to the "save" event in the Content Editor, so that I do not need to create a second, confusing Save button for my users.
http://www.markvanaalst.com/sitecore/creating-a-item-editor/
I am able to save my values to the item, but the values in the normal Content tab are also being saved, overriding my values. I have confirmed this via Firebug. Is there a way to prevent this, or to ensure my save is always after the default save?
I have this in as a support ticket and on SDN as well, but wondering what the SO community can come up with.
Thanks!
Took a shot at an iframe-based solution, which uses an IFrame field to read and save the values being entered in my item editor. It needs to be cleaned up a bit, and feels like an interface hack, but it seems to be working at the moment.
In my item editor:
jQuery(function () {
var parentScForm = window.parent.scForm;
parentScForm.myItemEditor = window;
});
function myGetValue(field) {
var values = [];
jQuery('#myForm input[#name="' + field + '"]:checked').each(function () {
values.push(jQuery(this).val());
});
var value = values.join('|');
return value;
}
In my Iframe field:
function scGetFrameValue() {
var parentScForm = window.parent.scForm;
if (typeof (parentScForm.myItemEditor) != "undefined") {
if (typeof (parentScForm.myItemEditor.myGetValue) != "undefined") {
return parentScForm.myItemEditor.myGetValue("myLists");
}
}
return null;
}
In theory, I could have multiple fields on the item which are "delegated" to the item editor in this way -- working with the content editor save rather than trying to fight against it. I'm a little uneasy about "hitchhiking" onto the scForm to communicate between my pages -- might consult with our resident Javascript hacker on a better method.
Any comments on the solution?
EDIT: Blogged more about this solution

Launch Content Editor from code

I have an application that is creating an new item in Sitecore then opening up the Content Editor to that item, it is loading fine but whenever i try to open the html editor i get a 'NullReferenceException'. This is only happening when i launch the application in this method.
Source Code:
[Serializable]
public class PushToCMS : Command
{
public override void Execute(CommandContext context)
{
//Context.ClientPage.Start(this, "Action_PushToCMS");
Database dbCore = Sitecore.Configuration.Factory.GetDatabase("core");
Item contentEditor = dbCore.GetItem(new ID("{7EADA46B-11E2-4EC1-8C44-BE75784FF105}"));
Database dbMaster = Sitecore.Configuration.Factory.GetDatabase("master");
DatabaseEngines engine = new DatabaseEngines(dbMaster);
Item parentItem = dbMaster.GetItem("/sitecore/content/Home/Events/Parent/");
// Load existing related item if it exists
Event evt = new Event(new Guid(HttpContext.Current.Items["id"].ToString()));
Item item = dbMaster.SelectSingleItem("/sitecore/content/Home/Events/Parent/Item");
if (item == null)
item = CreateNewEvent(engine.DataEngine, parentItem, evt);
Sitecore.Text.UrlString parameters = new Sitecore.Text.UrlString();
parameters.Add("id", item.ID.ToString());
parameters.Add("fo", item.ID.ToString());
Sitecore.Shell.Framework.Windows.RunApplication(contentEditor, contentEditor.Appearance.Icon, contentEditor.DisplayName, parameters.ToString());
}
The only difference i can tell in the loading of the two methods is the url to the html editor, however i dont know where this is being defined or how i can control it.
Launched through normal method:
http://xxxx/sitecore/shell/default.aspx?xmlcontrol=RichTextEditor&da=core&id=%7bDD4372AC-5D37-4C9E-BBFA-C4E3E2A27722%7d&ed=F27055570&vs&la=en&fld=%7b60D10DBB-7CD5-4341-A960-C7AB10347A2C%7d&so&di=0&hdl=H27055699&us=%7b83D34C8A-4CC4-4CD9-A209-600D51B26AAE%7d&mo
Launched through RunApplication:
http://xxxx/layouts/xmlcontrol.aspx?xmlcontrol=RichTextEditor&da=core&id=%7bDD4372AC-5D37-4C9E-BBFA-C4E3E2A27722%7d&ed=F27055196&vs&la=en&fld=%7b60D10DBB-7CD5-4341-A960-C7AB10347A2C%7d&so&di=0&hdl=H27055325&us=%7b83D34C8A-4CC4-4CD9-A209-600D51B26AAE%7d&mo
any help on this would be greatly appreciated.
Phil,
If it is not too late for the answer... :)
It might be the case that you run this code without the permissions to read the core database. In this case, when you try to call contentEditor. you'll get NullReference. I would recommend you using another format of running the application - use another method:
Sitecore.Shell.Framework.Windows.RunApplication("Content Editor", parameters.ToString());
If this doesn't help, please attach the stack trace of the exception you get.
Hope this helps.