Extjs4: beforeshow vs afterrender - events

What is difference between beforeshow and afrerrender events of extjs components.
Also can I get reference to any document which describes the order in which extjs events fire (or which describes steps which happen before the component is displayed on screen) ?

beforeShow listener is triggered only when you are toggling an extjs component using show()
afterRender is triggered for every extjs component after it has been rendered
Rendering happens before a show; it only makes sense that a component must already be rendered before it can be shown or hidden etc...
I don't know of any great documentation on extJS event occurrences/flow. This thread is about as good as I've seen: Explain ExtJS 4 event handling

Related

Primefaces slider <p:slider>: detect sliding

Is it possible to detect the event "while sliding" in a primefaces slider?
I have a poll (every 3 seconds the sliders are updated) to update the sliders' values (as multiple clients can use the slide).
When I am sliding and a periodic ajax call is made (by <p:poll>), the slider returns to its initial position. This behavior is understandable, because the form itself is refreshed.
I need to avoid this: when I'm sliding, I want the poll to stop. When I stop sliding the ajax event "slideEnd" is called. In this event, I would return the poll refresh process normally.
Is this possible? What would I need?
Edit: I found out about onSlide and onSlideStart attributes of <p:slider>. I used something like:
<p:slider for="porta2005" minValue="0.0" maxValue="100.0" step="1" styleClass="width-100" onSlide="#{dimmerBean.slideStart()}">
<p:ajax event="slideEnd" listener="#{dimmerBean.mudaTensao2005}" update="tensao2005"/>
</p:slider>
But the method slideStart() is called on every poll request inside bean, not only when I effectively slide. Is it wrong to call a bean method inside onSlide like this?
I am using Primefaces 6.1.
The onSlide, onSlideStart, and onSlideEnd are client side callbacks. So if a backing bean method is put in these attributes, it will be called during render, and not during the actual event.
From the documentation:
Name Default Type Description
onSlide null String Client side callback to execute during sliding.
And a little below this:
Client Side Callbacks
Slider provides three callbacks to hook-in your custom javascript, onSlideStart, onSlide and
onSlideEnd. All of these callbacks receive two parameters; slide event and the ui object containing
information about the event.
You can stop polling by using the poll widget functions. Suppose your p:poll has a widgetVar attribute as myPoll, you can pause it during sliding as shown.
<p:slider for="porta2005" minValue="0.0" maxValue="100.0" step="1" styleClass="width-100"
onSlideStart="PF('myPoll').stop()" onSlideEnd="PF('myPoll').start()">

JSF, AJAX and the rendered attribute

If you do JSF AJAX calls and change the component tree while rerendering (or between ajax calls), you'll get exceptions from Mojarra. As I understand it, it's difficult to recreate the component tree partially when the new tree is different as the one stored in the ViewState (or the actual JSF class). That's "ok". I'm thinking about using the rendered attribute and not rendering the component.
My question: How does the rendered attribute work? Does the component get restored and is the component tree, that JSF creates during restore phase, safe? We have a very dynamic XHTML page and not rendering object's instead of disabling them with css classes would really up the speed of the page.
I tried it and it works as expected. So JSF only assumes that the component is there even if it doesn't render anything.
Please consider that the view state does get restored and it's still a performance hit (but a smaller one as nothing get's sent over the wire and the output string/html doesn't need to be rendered).

Execute JScript when loading Entity from Sitemap

I have a custom entity which has an entry in the sitemap. When I load the entity in the main window, it opens the grid view on the right - standard behaviour so far.
I now want to change some thins in the DOM of the grid body. Therefor I should execute a Javascript while loading the grid. But I have not found any way to do this yet. I sthis possible?
My second way was to but the grid into an Iframe and then do the task on load. This works, but I loose all the buttons from the entity.
Thank you
The best (and probably only) way I can think of to attach javascript to the load of the homepage grid is to add your functionality to a CustomRule for an EnableRule for any object in the custom homepage grid ribbon, which will execute at the time the ribbon loads.
Only caveats: you probably will have to do some validation to make sure the grid is in the right readyState before changing anything, and you'll need to make sure to return true if you actually want that ribbon object to be enabled.

Display part of the data from view's model at a time (ASP.NET MVC 3)

I am completely new to ASP.NET MVC, so the question might sound silly.
I have a view that should display a part of the data from it's model at a time. And there are buttons that should trigger which part of the data gets shown.
So far, I have encapsulated each part of the data into a div and added buttons. I have also added a function that returns CSS style for a given id (basically, it returns display:visible or display:none).
I assume that I'll be able to wire up event handlers for buttons. But I am completely stuck at redrawing/updating of div elements. I mean I don't understand how should I cause divs to update their style.
Could you please help me to show/hide div elements and buttons dynamically?
That should be standard javascript (or in your case jquery). It is unrelated to MVC3. Once you have the view built that includes all your divs with content, you call $('#div_id').show() or $('#div_id').hide() to show or hide. You can also use many other methods that have related animations, but that should get you started.
http://docs.jquery.com/Tutorials:Basic_Show_and_Hide
Like this:
$('buttonClass/IDhere').click(function (){
$('theDivYouWantToShowClass/IDhere').toggle();
});

Jquery binds the click events sequentially after every .load()

I am loading a .php file into a div tag using .load() function of jquery :
$('#content').load('MY_URL');
I have bound several events using .live and all of them work fine after loading the MY_URL.
but the problem is : when I load the second page into the latter loaded page (suppose #content) the events are fired twice :
for example I have bound a click event to show and hide a div tag but after loading the second page it fires two times and shows and hide the div tag sequentially that you can say it doesn't work at all.
I have read all problems like this and I can say all their problems have been solved using .live instead of .bind but mine did not get solved ! please help me.
Unbind your first live event before firing 2nd live event
$('#content').die("click");

Resources