How to create single page application in liferay 7? - liferay

Can anyone share some detailed info on how to create a Single Page Application (SPA) in Liferay 7 using SennaJS.
I could't found any documentation on How to create SPA in Liferay 7.

It comes by default, except if you unset the following property:
javascript.single.page.application.enabled=true
BTW, it is rather annoying in dev instances, as it takes a while to load pages in the first access, sometimes you even need to reload the page. Also, be aware, in some especial cases, some applications might break, normally due to code that counts with page reloads to function properly.

you can even create it in 6.2 by using the following code.
// initializing senna
var app = new senna.App();
// Set links selector for navigations
app.setLinkSelector(".senna-link");
// set basic path of liferay site
app.setBasePath('/web/spa-demo/');
// Id of DOM element which will be replaced from
// next page request
// using content div - default in liferay theme
app.addSurfaces('content');
// define routes for all the navigation links
// route link = Base path + page link
app.addRoutes([
new senna.Route('home', senna.HtmlScreen),
new senna.Route('second', senna.HtmlScreen),
new senna.Route('third', senna.HtmlScreen),
]);
Thing which you need to take care of, if it is SPA, then all the events need to be bound first i.e. delegate as there is not going to be page refresh.
i.e things like document.getReady is only going to be called once.

Whatever the portlet you are going to create and deploy with Liferay SDK/Workspace OR any compatible liferay plugin it will be SPA by default.
No need to do any coding on top of it.

Related

Custom Route for ServiceStack Razor Content Pages

I have the following content page: /folder/_new.cshtml
My intention is to have the page accessible through the following url: /folder/_new
However it seems that such file name is not mapped to the url. Is there any workaround to make it happen, perhaps by assigning a custom route instead of relying on the pretty-url-by-default feature?
This is a pre-defined restriction for not allowing views starting with a _ prefix to be called directly, the restriction can be removed when you're registering the ServiceStack.Razor plugin with:
var razor = new RazorFormat();
razor.Deny.RemoveAt(0);
Plugins.Add(razor);

Is it possible to change default sharepoint 2013 app url

The default app url looks like http://[app prefix]-[app id].[domain name]/[site collection path]/[app path]/pages/default.aspx.
It is unconvinient because every deployment during development generates new url. And after development stage the end users need a permanent link to the application, but every bug fixes or updates that will be deployed will cause new app url generation. Is there right way to fix the app url?
You can create a URL controller:
Create a list that would contain two fields: fakeUrl, realUrl,
fakeUrl can be something like "http://staticappname.[domain name]/[site collection path]/[app path]/pages/default.aspx"
realUrl would be your http://[app prefix]-[app id].[domain name]/[site collection path]/[app path]/pages/default.aspx
Give your users fakeUrl
Create a HTTPModule that would read the list and redirect the http request to the realUrl
After you redeploy your app, just change the realUrl in the list
***I'm not if this is your case but you could change your app to be a provider-hosted. Then you would get a static Url
You can open your SharePoint hosted add-in using an alternate link like:
http://[SharePointSite]/[Add-inName]
For eg.
http://contoso.com/sharepointhostedapp/

Render mobile version of login in Secure class Play! Framework

Is it possible to somehow override the login method of the Secure.java class of the Secure-Module in Play! Framework, so that another version of the login form is displayed?
In my case, i want to display a mobile version of the login-form if a mobile browser is detected.
I know i should not change the Secure.java class itself, but i don't really see any other solution to this problem.
As discussed in other posts you have the request in your Play! controller. So in this request you could ask which agent is trying to view your website:
String agentInfo = request.headers.get("user-agent");
The you can determine which template will be rendered for this agent:
if (agentType.isWhatEverHeIs) {
renderTemplate("Application\mobileTemplateForBadPractise.html");
} else {
render();
}
But what I would encourage you to do is responsive webdevelopment. Create your templates as smart as possible, let the template and css and javascript do this and keep your business logic in your controller.
You could use the Twitter Bootstrap to achieve this, but there are many more! Like Skeleton.
You even got the request object inside your templates so that you can optionally render things in your template (or not) based on the agent.
Even simpler, simply create/override the secure/login.html template and use responsive design : media queries. No need to change the controller or check agent or whatever.

TYPO3: extension with both backend module and frontend plugin

I am trying to create an extension ('XML Uploader') with a backend module and a frontend plugin also.
The backend module will be used for managing xml files (upload, validate against a DTD), and the frontend plugin should be used for displaying the uploaded xmls.
The problem is with the frontend part:
I followed
the basic extension tutorial - added a new page, created a content element of type 'Insert plugin' - but when trying to add a new record, the type 'XML Uploader' does not appear in the list of new record types. Moreover, the changes made to class.tx_xmluploader_pi1.php have no effect.
So how should I work with the frontend plugin? Or would it be better to create a separate extension instead?
Any help would be very much appreciated.. Thank you.
When creating your table with the extension kickstarter you must check the "Allowed on pages:" checkbox to allow records from this table to be created on regular pages.
If your changes have no effect, it could be that the page is cached by typo3. In that case you can clear or disable the cache with the admin panel or in the page configuration menu.
You have to include the static template of your extension (I presume you used the kickstarter or extension_builder):
go to the your template, in the object browser you should see something like:
plugin.tx_xmluploader_pi1 = USER
if you can't find it, edit your template (edit/modify => edit whole template record) and add your extension template in the tab 'Includes'
Additionally, check your ext_localconf.php for the line
t3lib_extMgm::addPItoST43($_EXTKEY, 'pi1/class.tx_xmluploader_pi1.php', '_pi1', 'list_type', 0);
This is where your FE plugin is being registered.

SharePoint 2007 deploy MasterPage as Feature delete files on deactivation

I have a MasterPage that I am deploying to a SharePoint 2007 server. I am using a feature and a wsp to do the deployment. After deployment, my new masterpage isn't available to select and use for my site. Then, if I activate my feature, I am able to select my master page. But, when I deactivate my feature (or even retract the solution and delete it from SharePoint), the master page is still available for selection and all of the other files that were part of my feature/solution are still on SharePoint. So, is there any way to remove the master page from being available when my feature is deactivated, and then if it gets activated again, have it be available again?
Hope this makes sense, thanks.
SharePoint doesn't by default clean up files deployed as part of a feature activation.
In order to remove the master page and other associated files you'll need to write a feature receiver for your feature, implement the FeatureDeactivating method, and remove your files using object model code instead of CAML. MSDN document for feature receivers is here, and there are blog examples of writing feature receiver code all over the web.
Bear in mind that in order to remove your master page you'll first need to make sure you reset the master page for all sites in the site collection to the default/another available master page. You'll also want to be careful not to remove resource files (CSS, images, etc.) that are shared among master pages or page layouts.
First make sure you are not using the Master page anymore in the feature deactivating. Then you can remove it.
SPWeb web = (SPWeb)properties.Feature.Parent;
string customMasterUrl = (new Uri(web.Url + "/_catalogs/masterpage/Sample.master")).AbsolutePath;
if (web.MasterUrl != customMasterUrl)
{
try
{
SPFile file = web.GetFile(customMasterUrl);
SPFolder masterPageGallery = file.ParentFolder;
SPFolder temp = masterPageGallery.SubFolders.Add("Temp");
file.MoveTo(temp.Url + "/" + file.Name);
temp.Delete();
}
catch (ArgumentException)
{
return;
}
}

Resources