Primefaces p:poll tag - java

I am using the p:poll tag to display a live chart. I am using jfrecharts here so , basically the poll will update the image every 15 sec.
The problem is that i need to render an image soon as the page loads. But instead the poll delays from the first load. Is there any way to set the initial poll interval to Zero and for all other subseequent ajax calls poll with 15sec interval.
Regards,
Gayan

Invoke same action method (of the p:poll) on page load
like described here:
JSF 2 invoke action method on page load
---OR---
You can execute the same action of the p:poll on page ready , for example make a button with same action , make it hidden and on page load you can .click() on this button with jQuery.
---OR---
Set the interval value to something like #{myBean.intervalValue} , and setting intervalValue into zero , and on the pool method check if its zero and if its so set it to 15 (dont forget to update the p:poll itself so it will reevaluate the intervalValue)

Related

Is there a recyclerView equivalent in web?

I have a webpage that I made with spring framework in java. In some of the pages they can get a list of clickable rows, but if you select a range that is too large fe. 1000 rows, it freezes and the javascript needs some 20 seconds to put buttons and such on each row.
I know that in android developement one would use recyclerView to load only a portion on the screen and would load more as you keep scrolling. Is there something similar I can use in my webpage to achieve a similar result?
What I ended up, using was infinite scroll https://scrollmagic.io/examples/advanced/infinite_scrolling.html
then I seperated my JSP list page strictly from the "forEach" part into an another JSP document that the first JSP would call using something like
$.get("${endpointName}"+"?queryIteration="+ queryIteration+ extraVariables, function( data ) {
$("#mycontent").append(data);
if($("#queryCounter"+(queryIteration)).val() === 'true'){
$("#loader").hide();
}
end then in the endpoint I would add
model.addAttribute("endpointName", "listMaterialTests");
model.addAttribute("queryIteration", queryIteration);
if(queryIteration==null || queryIteration==0)
return "materialTestList";
return "materialTestListRows";
I would modify the services to load 100 rows at a time depending on what the queryIteration value is

How can I get returned value from function in .jsf page adf 12c?

I am calling a function on page load (.jsf page programmatically) and it's working fine, but function is returning (0 or 1) string value. I want to show or hide buttons based on returning value in jsf page.
How can I get returning value on .jsf page?
How can I apply logic of show and hide based on returning value?
Here is how I am calling function on page load
<f:metadata>
<?audit suppress oracle.ide.xml.validation-error?>
<f:event type="preRenderView" listener="#{backingBeanScope.backing_login.viewPrivilidge('Program')}"/>
</f:metadata>
Here is the code of button on which i want to apply logic
<af:button text="Supplier" id="b4" inlineStyle="width:190px;"
destination="Supplier_Setup.jsf" icon="#{resource['images:supplier.png']}"/>
I am using .jsf page in adf 12c.
Be careful with the use of Rendered. Rendered = false prevents any markup from being generated for that component. That means you can't simply set rendered = true on the component and expect it to appear - it won't. In this case you have to refresh a containing layout manager to get it to render. You probably want Visible=false here, then the markup is generated for the component and setting visible = true will make the component appear.
Rendered is often reserved for secure components where you do't want the markup in the page source at all.
only you need to call function in render attribute of that tag where you want to apply logic
<af:button text="Supplier" id="b4" inlineStyle="width:190px;"
rendered="#{backingBeanScope.backing_login.viewPrivilidge('Program') == '1'}" destination="Supplier_Setup.jsf" icon="#{resource['images:supplier.png']}"/>
"#{backingBeanScope.backing_login.viewPrivilidge('Program') == '1'}" .......... if your returning value is equal to '1' then it will render otherwise it will not render

Using AnimationManager from Android-pdfview

I am using Android-pdfview library to display pdfs within my application.
pdfView.fromFile(new File("/path/to/file")).defaultPage(1).enableSwipe(true).onPageChange(this).load();
How to use AnimationManager from Android-pdfview library ?
For example, I want to show each page for 10 seconds, and move to next page automatically without user interaction. Once last page is reached, loop again.

Element in View port issue [Peculiar]

I am getting the following error in a peculiar fashion.
The point at which the driver is attempting to click on the element was not scrolled into the viewport.
The user story goes like this, if a selection is made in a check group, corresponding div with few fields will be enabled. Similarly for n-number of selection there will be n-number of DIVs. When i select only one option in the div, it works as expected but not for the multiple options.
i have read some stuffs and tried all the possible combination about the above said view port issue. My work around attempts and the outcomes are given below.
1) Tried with the Advanced interaction method. (Action class) - The same exception
2) Accessed with java-script executor- same exception
few more will be updated soon.
I have tried all the combination of locating mechanism. Everything works perfect and the element is in visible mode. But when i perform any operation on the second DIV values i am getting the above said exception.
what can be possibly done to get the element in working mode?
EDIT :
1.The DIV elements all are in view port and they all are accessible individually.
2. Div are enabled as per the check box selected
3.In a scenario, if we choose two check box, after a first selection you can edit the DIV and for the second selection the DIV will not be accessible.
4. both DIVs are identical with respect to the elements/attributes/properties of the elements.
5. When a Active div is edited no other div will be available in the UI.
For some reasons i was not able to produce the Reproducible code here.
i sorted out the problem. There was actually a frame for every DIV. these frames are just hidden after the edit and a fresh frame is opened every time, so when i access the second div i had to choose the latest frame.
i just polled for the number of frame and proceed with the latest one.

Dragging, Dropping & resizing elements

I have a web page which has three <div> elements:
Right_bar contains several layouts (nothing to do with this question)
Bottom_bar contains several components e.g. calculator, logo, a group of buttons etc. each component uses a <div> and must be resizable and draggable.
And a Working Area, where all the components are dropped & resized. Also a user can resize & change the location of components anywhere in the Working Area. Once a user sets a component then the page must be saved in same style and it shouldn't be changed even after refreshing the page.
My questions are:
Should I use a database to save the location of component.
Which one should I use: JQuery / AJAX / anyother?
If you know of any tutorials please let me know although I am beginner in JavaScript, Basically a Java programmer.
Note: on the server side I am using Servlet.
Whenever the user drops an element, launch a simple Ajax request that will pass the new value to the server.
try {
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); // IE
}
catch(e)
{
var xmlhttp = new XMLHttpRequest(); // Other browsers
}
xmlhttp.open('GET', 'yourServerScript.url?param=value', true);
xmlhttp.send(null);
You may want to check if the request succeeded or failed by handling the "readystatechange" event of your http request, but that doesn't seem important in your case.
After that you just have to get the value server-side, store it in a session variable, and then on every page load, check if there is a session variable defined for the parameter before setting it to its default value.
What you can do is save the location of the control in a xml and save it in a table.
2.jquery UI has as build in framework that supports drag and drop div elements, check this link http://jqueryui.com/demos/droppable/
I did the same thing for an application. (but I used PHP, anyway it doesn't matter for what you need)
I used jQuery + jQuery UI drag & drop / resize
I used AJAX with 4 parameters (x,y, z-index and id of the element) for drag & drop on drag stop
I used XML as a database for this, but any database (or any persistance way) will do the trick. As #Thibault Witzig said, take the most pertinent for your project.

Categories