JSP code to display a JFreeChart using Struts2 - ajax

All,
I have been trying to use this guide to render a JFreeChart on a JSP page. Could someone help me out with the JSP code required to show this on a tabbed panel using the struts-dojo-tags.
Eventually I want to render a different graph on each tab and refresh them using AJAX.
At the moment I have configured everything as shown in the link.
Update:
Here is the code from the struts2 guide which I am using:
<sx:tabbedpanel id="tabContainer">
<sx:div label="Local Tab 1" >
Tab 1
</sx:div>
<sx:div label="Remote Tab 2" href="%{#url}">
Remote Tab 2
</sx:div>
</sx:tabbedpanel>
Where url refers to my action which returns the chart result. This returns a lot of symbols on the tab so clearly it can't show the returned png.
I can also view the chart if I insert <img src="http://localhost:8080/myApp/myaction"> so the action does work correctly.
Do I need to create another JSP page which the url can point to which simply contains an image which gets a chart from my action?
Thanks,
Alex

I would suggest that you start gradually in steps
Make sure that the chart is indeed created (already done)
Create a single HTML page with an img tag that points to the url (see if this works)
Create a single JSP page with an img tag (see if this works)
Create a Struts 2 JSP page with an img tag (see if this works)
Create a Struts 2 JSP page with an img tag in a tab (see if this works)
Create a Struts 2 JSP page with an img tag in a tab that updates dymanically with Ajax
This way you can isolate the problem instead of throwing everything in the mix at once.
But in general you do NOT need another JSP page that contains the image.

Related

AngularJS ng-repeat don't see scope variable - in WYSIWYG editor loaded with AJAX?

I'm modifying a website, built with AngularJS, and in one page I have a WYSIWYG editor.
The whole widget that includes the editor, is a div that has 'ng-controller="TextsController"'.
In this div I have a button, clicking on it displays the editor. And the initializing of the editor happens in a directive - "richTextEditor".
So - I'm making a popup in this editor, that has to show some images from the server. I put the code for pulling the images in the controller ... and there I set
$http.get('/url/to/files').success(function(data) {
$scope.imagesFromServer = data;
});
and in the view I have
'ng-repeat="image in imagesFromServer"'
And the problem is that the ngRepeat doesn't see any items.
I have two ideas:
The view, containing the ngRepeat (the HTML for the editor, and the popup with the images as well) loads with AJAX, and at that very moment the scope variable is not set.
I'm initializing the scope variable in the wrong place. (Eventually has to be in the directive instead of the controller? ... but all examples I've seen and done so far - pull every data in the controller, and the view sees it directly.)
Hope I've described the situation clearly.
Thanks in advance.

show only the content of article

how do I only show content in a single article?
I am using Joomla 2.5 and Ajax to call a single article, but when I render the article in a <div> tag, I render again the header, the footer and all the page , but I only want the content.
How do I configure the page or the article to show only the content?
If you only want to get component you can append tmpl=component parameter with the url.
Your article url will be like this-
index.php?option=com_content&view=article&id=1&tmpl=component
Or you can try like this-
$('#result').load('index.php?option=com_content&view=article&id=1&tmpl=component #container');
Loading Page Fragments

Is it possible loading a different code of html in the same division? Based on anchors clicked

I mean without requiring to refresh the whole page, Is it possible to load a part of html code through Ajax into the same division.
eg. If the user clicks on the PROFILE anchor (not having href) the anchor should generate request-object and load the content corresponding to PROFILE in the division below it??
Similarly if he clicks SETTINGS it should load settings details in the same division which was used to load the profile.
Yes you can do this. After you do the ajax call, once you get the response, you can bind it to the div. For this set some id to the div, do the document.getElementById('id').innerHTML = 'Your html response'.
Try exploring jQuery.
Hope this helps.

Problem with partial views and tinymce

In a view (master view) another view is called with $this->load->view(‘sub_view’);
In the sub_view i have a textarea to use with tinymce.
If I combine the views in one single view and call it from my controller my js works fine and the textarea converts to tinymce editor.
If i use the master - sub scenario and my js targets elements in the sub_view although the same html is returned to the browser js doesn’t fire up correctly and instead of my textarea the whole div that is contained in the sub_view is converted to tinymce. It's like if the contents are loaded afterwards or something.
By the way if i setup just an onclick=alert"()" in the subview it fires up.
Edit: You can grab an example from codeigniter.com/forums/viewthread/179792
Figured it all out.
It had nothing to do with either codeigniter or tinymce
It was markup error
in the main view there was a and the textarea id was also content.
I don't know why it worked correct in full_view
In the init it was 'textarea.tinymce' and textarea had class='tinymce' while the div had the same id too but was not a textarea.
but in the sub_view the wrong markup caused errors.
Changing ids fixed it
Thanks anyone for taking time to review the problem.

Need Jquery Carousel [slider animation] with HTML and AJAX

i need a jquery plugin where i want to load the module by default as HTML and upon clicking more link it should load the rest of the content via AJAX and then previous button should be enabled.
Currently when i google i can get lot of plugin which just load either via AJAX or Animation [by hidding the rest of the content]. But for performance issue i don't want to load all the content at one shot and then animation. So i want to load the 5 li's and upon clickiing "More" it should start loading the remaining content but it should also animation.
Could someone help me on this?
-- Bala
My advice to you would be to customize the jCarousel according to your needs. Specifically, when you render the page initially you can include the initial 5 elements of your carousel. Then, in the carousel's onchange event, once you reach the last slide you can use AJAX to pull in the additional images.
Depending on your needs, using jCarousel driven by a flat JavaScript array you could save some load time as the image URLs would be rendered in the original markup, but not downloaded by the browser until they are added to the visible portion of the carousel. No AJAX required. Here's a demo.

Resources