How to create wizard/screens with disabled pages/buttons using Dojo Dijit? - dojo

I want to create a sequence of screens using a StackContainer in Dijit.
However, I want to disable consecutive pages and their corresponding buttons in the StackController until the form on the current page has been validated successfully.
Is this possible with the standard elements? If so, how?
In addition, it would be nice if I could customize the buttons of the StackController to show my own details instead of the title of the screen.

For disabling I think you can use
the_button.set('disabled', true); //and vice-versa
For changing the details you can try setting the labels directly (similar to disabled) or try subclassing the appropriate stuff (probably the stackcontroller) if it turs out to be feasible.

Related

Duplicate dijit widget instead of recreating it

Is there a way by which I can duplicate or clone dijit widgets?
Basically, idea is to improve page rendering performance by minimizing widget creation time.
We have a single page web application and we do not reload the entire page whenever the user performs any action.
The flow of events is as follows,
The main page is loaded by the browser. It contains a dijit ContentPane which acts as a master container and displays the entire page using various other dijit widgets like textboxes, tabs, datefield, Enhanced grid etc.
The user performs an action (e.g. click on a dijit button)
The application sends an ajax call to server which processes the button click event and generates UI of the next page.
Browser receives successful response from ajax call and calls refresh method of dijit ContentPane. Which triggers destruction of existing widgets and new set of widgets are created and placed at appropriate position. (instead of refreshing the entire page)
The user again performs some action and again the refresh method is called which triggers destruction of existing widgets and new set of widgets are created and placed at appropriate position.
Because of such architecture the browser has to destroy existing widgets and recreate them again and again. Which results in slow performance.
The idea is to have a set of widgets always readily available on the browser clone them and place at appropriate position and update them instead of recreating each time.
Yes this is possible with something called _AttachMixin.
Basically there is no getting around the fact that your widgets would need to attach event listeners to the HTML Document. What can be cut out though is the time in the Dijit Widget's lifecycle to generate the DOM. As we well know, simple Dijit widgets like a dijit/form/Button has a div inside a div inside a div etc.
This is explained in detail here http://dojotoolkit.org/reference-guide/1.9/dijit/_AttachMixin.html
Here is an example using Node.JS as a backend. http://jamesthom.as/blog/2013/01/15/server-side-dijit
This is a tough problem and this concept isn't explained very thoroughly. If you have a backend that is not Node.JS you have to manually make the widget string and pass it as a response to your AJAX and an follow the example from the 1st link (Ref Doc)
We have had lots of widgets of our app render nicely within the client side. A far less complicated approach would be to simply show / hide (instead of render and destroy) widgets as and when they are needed. I assume that you app's access policy would focus on data and not which person has access to which widget.

Flag module - link's position change (Drupal)

I've just installed Flags module and it looks awful when on the bottom I see "Flag this item" link. The only thing I've found in configuration is enabling it to show as normal link. Still I haven't found how to change position of this link. Is it even possible to change link's place? I have installed CCK Blocks but it doesn't give me any option to get rid of it. If someone know or suspect what's possible - please help me.
Try the Display Suite module, this module is integrated with many modules like flag, title etc...
Display Suite allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your
nodes, views, comments, user data etc. the way you want without having
to work your way through dozens of template files. A predefined list
of layouts (D7 only) is available for even more drag and drop fun!
https://drupal.org/project/ds
You can move and generate custom layouts for the fields/properties on the entity display formatter: teaser, full...

jQuery Mobile does not process elements in Partial View

I'm converting my site from using jQueryUI to jQuery Mobile, and I'm having some trouble.
I have a page that lets users add new timesheet entries. They click the "Add" button and it retrieves a Partial View from the server right onto the page.
The problem is that jQuery Mobile is not applying to any of the elements in the Partial View.
How can I force jQuery Mobile to process my elements after they've been inserted into the page?
The short answer is that you can just trigger the create method on the parent element of where you inserting your partial view.
For example $('#container').trigger( "create" );
Alternatively most widgets can be manually initialized by calling them on the element, for example for a listview: $('#myListview').listview(). This can be useful if you have only a few elements that need to be enhaced and you don't want to traverse all the child elements of the container. You should also know that for many widgets there is also a refresh method which you can call if you add elements to it after it has already been initialized for example $('#myListview').listview('refresh).
Also have a look at the following Q & A from the JQM docs which deals with this issue and for an explanation as to why it is necessary to call these methods.
Question: Content injected into a page is not enhanced.
Answer:
jQuery Mobile has no way to know when you have injected content into a
page. To let jQuery Mobile know you have injected content that must be
enhanced, you need to either make sure the plugins are called to
enhance the new elements or trigger("create") on the parent container
so you don't have to call each plugin manually.

Show but disable a view in Eclipse-RCP

I have two views in my RCP application, wherein I'm performing a task(background operation),the status of the operation is shown in view1. What I'm trying to achieve is that,during the task in progress, user shouldn't able to move/traverse to other views.They(other views) should be disabled.
As a workaround i tried using the showView method of IWorkbenchPage.
activePage.showView(view.ID,null,IWorkbenchPage.VIEW_VISIBLE);
I've used the three constants VIEW_VISIBLE,VIEW_ACTIVATE,VIEW_CREATE. None worked in my case though.By the way in showView method signature, i could not figure out what is a secondary id.
Below is the simulated demo of my problem
here the user can traverse to view Demo,during the operation, which shouldn't be actually.
How can i resolve this, any ideas please?
You can't really disable a view (there is no notion of "disabled views"). The only thing you can do is hide it. Use the hideView() method to do that.
Another way of doing it would be to use the ProgressService to display a modal progress dialog while the operation is progressing. This way the user must wait until the operation is complete before they can interact with the UI.
PlatformUI.getWorkbench().getProgressService().run(true, false, runnable);
See http://wiki.eclipse.org/FAQ_Why_should_I_use_the_new_progress_service%3F
You can disable a view like you disable any other SWT control: by setting setEnabled(false) on the top Composite. Often done by overriding ViewPart.showBusy(...)...

How to change the url of my entire page when a new tab is selected? (Dojo-Tabcontainer)

I have used Dojo-Tabcontainer to create tabs. I want to have a separate template for every tab. So, when a tab is clicked I want a new page to be loaded and the url to be changed.
Can you please suggest a way to do this using Markup instead of programmatic way?
I'm thinking of using Template Inheritance while creating html page for each tab to avoid redundancy.
I can get some clue from this:
How to change Dojo TabContainer behaviour to simply open an external link instead of showing a ContentPane?
But I'm not sure how to do it via Markup instead of programming.