Jar file for HttpRequestHandler in lwuit in j2me - java-me

I need to open a web page in j2me emulator. As I have the flow that I can do this by using HTMLComponent. But I can not use this HttpRequestHandler class to create handler in j2me in Lwuit can anybody say me what is missing in my j2me? If is there any JAR file to use it then give me suggestion to make use of it. Then I have also tried DocumentRequestHandler in the same instead of HttpRequestHandler But it show me emulator that "Error in connecting stream"
My code is:
DocumentRequestHandler handler=new DocumentRequestHandler() {
public InputStream resourceRequested(DocumentInfo di) {
return null;
// throw new UnsupportedOperationException("Not supported yet.");
}
};
HTMLComponent htmlc=new HTMLComponent(handler);
htmlc.setPage("http://facebook.com");
addComponent(htmlc);
show();
In this code what i need to return in DocumentRequestHandler?

The class you are looking for is available at LWUITBrowser sample application and can be checked out from the LWUIT SVN under MIDP/applications.

Related

Why my custom C# extention does not execute when deployed to Spotfire WebPlauer/Consumer

I have a simple custom Add-in that just displays a message to the user.
namespace GeorgiSpotfireCustomExtention
{
public class GeorgiEvent : CustomApplicationEventHandler
{
protected override void OnApplicationInstanceCreated(AnalysisApplication application)
{
base.OnApplicationInstanceCreated(application);
MessageBox.Show("On Application Instance Created");
}
}
}
That is my CustomAddIn class:
public sealed class CustomAddIn : AddIn
{
// Override methods in this class to register your extensions.
protected override void RegisterApplicationEventHandlers(ApplicationEventHandlerRegistrar registrar)
{
base.RegisterApplicationEventHandlers(registrar);
registrar.Register(new GeorgiEvent());
}
}
I am just trying to learn the package deployment process. When I am running it locally - in the installed Spotfire Analyst client it displays the message just fine:
However, when I package the extention, add it to the server (via the "Deployments & Packages" section, adding the "spk" file and then saving the area, the message is not shown when I try to open a document in the WebPlayer/Consumer.
Notes: I am choosing "TIBCO Spotfire Any Client" for my intended client in the Package Builder when building the spk file.
from the Spotfire Wiki (emphasis mine):
WinForms graphical user interface is a component of the .NET Framework and not something supplied by Tibco Spotfire. It's not recommended to implement solutions using Forms, but sometimes it could be handy when debugging. There is no commitment that it will work in future versions of the Analyst client. Forms are not supported on the Web Player.
the example listed on the wiki is for IronPython, but presumably the same holds true for C# extensions.
Correct. My assumption, and I don’t really know a lot about .NET, so this is not absolute, is that the form is rendered on the machine executing the code. In the case of your example above, the dialog would pop on the Node Manager host. If you’re really set on using an alert like this, you can accomplish it in JavaScript with an ‘alert()’. There is probably a way to render dialogues o in the web client too, but I don’t know it offhand.

Where is the ios LocalStorage when using PCLStorage for Xamarin forms?

I am using PCLStorage to store image in localStorage and access them via path returned.
Its working fine but the problem is, whenever I again start debugging the application, images are not accessible.
Where actually it stores images in Local Storage? Is it not permanent location?
I want to store images in fileSystem and related data and image path in sqlite. Its an offline application so need to store this data permanently.
Any suggestions for this would be helpful.
Thanks
Try below steps.
The interface is fairly simple because we're really only interested in passing the byte array and a filename when we save the image to disk.
public interface IPicture
{
void SavePictureToDisk (string filename, byte[] imageData);
}
DependencyService will delegate image saving to the appropriate class. The usage for the DependencyService is:
DependencyService.Get<IPicture>().SavePictureToDisk("ImageName", GetByteArray());
Create Classes in Platform-Specific Projects
iOS Project
[assembly: Xamarin.Forms.Dependency(typeof(Picture_iOS))]
namespace ImageSave.iOS
{
public class Picture_iOS: IPicture
{
public void SavePictureToDisk(string filename, byte[] imageData)
{
var MyImage = new UIImage(NSData.FromArray(imageData));
MyImage.SaveToPhotosAlbum((image, error) =>
{
//you can retrieve the saved UI Image as well if needed using
//var i = image as UIImage;
if(error != null)
{
Console.WriteLine(error.ToString());
}
});
}
}
}
I got the answer for this question on Xamarin Forum so just updating the link here so it can help others.
https://forums.xamarin.com/discussion/comment/217282/#Comment_217282
As explained here that everytime we redeploy app the core path changes thats why on redeploying I was not able to find images on the path where I saved it. So now I am only saving the partial path like the folderName\the image name and rest of the core path I am finding on runtime.
This solved my problem.

ResourceEditor LWUIT NoClassDefFoundError: com/app/XMLMidlet: com/sun/lwuit/events/ActionListener

I have developed Rss App LWUIT Project using ResourceEditor.
I opened the project in Netbeans IDE, I followed the link at developers Nokia site Generating the NetBeans project in the Resource Editor - Adding GUI resource file manually into your project.
While running my application, I am facing Uncaught exception
java/lang/NoClassDefFoundError: com/app/XMLMidlet: com/sun/lwuit/events/ActionListener
Could I do any extra thing?
copy the res file to your package folder,
then,
Display.init(this);
try {
Resources r = Resources.open("/resource.res");
UIManager.getInstance().setThemeProps(r.getTheme(
r.getThemeResourceNames()[0])
);
} catch (java.io.IOException e) {
}

Examples of EventKitUi or EventKit in Monotouch

I am new to app development, but have developed in .Net sense inception. I was wondering if someone has any examples of how to use the EventKitUI.
My goal is to have a calendar view in my app and then if they choose to add it to their calendar they can.
I also want to be able to link to pdf documents from the content of the event.
Do you mean something like this?
class Testclass{
public event EventHandler Clicked;
public Testclass{
}
public void FireEvent(){
if(Clicked!=null){
this.Clicked(this,new EventArgs());
}
} }

How to use ASP.NET Session State in an HttpHandler?

I have an HttpHandler that is run on a client page (cross domain, not on our IIS server, etc) and when they click on our embedded link it fires off the Handler on our server. So far everything is working normally.
I am now trying to use the System.Web.HttpContext.Session object but it is null. I am thinking it is null because we don't have a session until our HttpHandler is invoked? And multiple calls to the handler will create a new session per call? If this is the case did MS just disable the Session object when calling into a HttpHandler? Can anyone confirm this?
If this is the case, what do you do to maintain state between calls? Some sort of SQL based data object? A file?
TIA
Have your HttpHandler implement the IRequiresSessionState interface. It will enable session state use.
IRequiresSessionState can be found in the System.Web.SessionState namespace.
I think you have to implement the empty interface IReadOnlySessionState, so the context will be loaded.
edit to add:
According to Michael Morton's answer, you can also implement IRequiresSessionState, which will give you write access also to the Session object
using System;
using System.Web;
using System.Web.SessionState;
public class DownloadHandler : IHttpHandler, IReadOnlySessionState
{
public bool IsReusable { get { return true; } }
public void ProcessRequest(HttpContext context)
{
context.Response.Write(context.Session["kmx"]);
}
}
try using the current context...
System.Web.HttpContext.Current.Session

Resources