Event only triggers if double click an element from sap.m.List - list

I have a SAPUI5 splitapp with a detail page. This detail page contains a list with ObjectListItems. I want to listen to a press/selection of this item, but I always have to press two times to an element, else the event does not get triggered.
Does anybody know what is the reason?
Thanks and best regards
Detail XML
<Page
id="myJobsPage"
title="{i18n>myJobsTitle}">
<List
id="myJobsMasterList"
inset="false"
items="{testkunden}">
<ObjectListItem
id="myJobsListItem"
visible="true"
title="{job}"
number="{offen}"
numberUnit="Euro"
press="onMyJobsListItem"
type="Active">
<!-- visible part -->
<ObjectAttribute
id="Gpart123"
text="Partner: {gpart}"
visible="true" />
<ObjectAttribute
id="Anrede123"
text="{anrede}"
visible="true" />
<ObjectAttribute
id="Name123"
text="{vorname} {nachname}"
visible="true" />
<ObjectAttribute
id="Strasse123"
text="{strasse} {hausnr}"
visible="true" />
</ObjectListItem>
<!-- <ObjectStatus text="{i18n>myJobsObjectStatus}" /> -->
</List>
</Page>
</mvc:View>
Controller
onMyJobsListItem: function(event){
console.log("only triggers if click twice");
};
UPDATE:
Splitapp Root View
<mvc:View
controllerName="mobile.splitapp.controller.App"
displayBlock="true"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" >
<App id="app">
<SplitApp id="splitapp" >
<masterPages>
<mvc:XMLView viewName="mobile.splitapp.view.Master" id="master1" />
</masterPages>
<detailPages>
<mvc:XMLView viewName="mobile.splitapp.view.MyJobs" id="myJobsPage" />
<mvc:XMLView viewName="mobile.splitapp.view.DisconnectionOrder" id="disconnectionOrderPage" />
</detailPages>
</SplitApp>
</App>
</mvc:View>

Here is a running example of your code (see below of jsbin, and the updated jsbin) and it runs just fine! Since you did not post your "surrounding" code I cannot tell what's wrong. But as you can see in the example below the event is triggered directly after the first press...
Cann you see a difference to your code?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>SAPUI5 single file template | nabisoft</title>
<script src="https://openui5beta.hana.ondemand.com/resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-libs="sap.m"
data-sap-ui-bindingSyntax="complex"
data-sap-ui-compatVersion="edge"
data-sap-ui-preload="async"></script>
<!-- use "sync" or change the code below if you have issues -->
<!-- XMLView -->
<script id="myXmlView" type="ui5/xmlview">
<mvc:View
controllerName="MyController"
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc">
<App>
<SplitApp>
<masterPages>
<Page
id="myJobsPage"
title="Master Page">
<List
id="myJobsMasterList"
inset="false"
items="{/Customers}">
<ObjectListItem
id="myJobsListItem"
visible="true"
title="{CompanyName}"
number="{offen}"
numberUnit="Euro"
press="onMyJobsListItem"
type="Active"/>
</List>
</Page>
</masterPages>
<detailPages>
<Page
title="Detail Page">
<List
inset="false"
items="{/Customers}">
<ObjectListItem
visible="true"
title="{CompanyName}"
number="{offen}"
numberUnit="Euro"
press="onMyJobsListItem"
type="Active"/>
</List>
</Page>
</detailPages>
</SplitApp>
</App>
</mvc:View>
</script>
<script>
sap.ui.getCore().attachInit(function () {
"use strict";
//### Controller ###
sap.ui.controller("MyController", {
onInit : function () {
this.getView().setModel(
new sap.ui.model.odata.v2.ODataModel("https://cors-anywhere.herokuapp.com/services.odata.org/V2/Northwind/Northwind.svc/", {
json : true,
useBatch : false
})
);
},
onMyJobsListItem: function(event){
alert("press");
}
});
//### THE APP: place the XMLView somewhere into DOM ###
sap.ui.xmlview({
viewContent : jQuery("#myXmlView").html()
}).placeAt("content");
});
</script>
</head>
<body class="sapUiBody">
<div id="content"></div>
</body>
</html>

Related

Sitecore 8, .NET 4.6, Bundles Returning 404

I am running Sitecore 8 (Update 5) on .NET 4.6 and am running into an issue with Bundles returning a 404 error.
My layout view:
#using Sitecore.Mvc.Presentation
#using Sitecore.Mvc
#model RenderingModel
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>#Model.Item.Fields["Title"]</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
</head>
<body>
<h1>#Html.Sitecore().Field("Title")</h1>
#Html.Sitecore().Placeholder("content")
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js" type="text/javascript" defer="defer"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
#Scripts.RenderFormat("<script type=\"text/javascript\" src=\"{0}\" defer=\"defer\"></script>", "~/bundles/scripts/footer")
</body>
</html>
My /Global.asax.cs file:
using System.Web.Mvc;
using System.Web.Optimization;
using Glass.Mapper.Sc;
namespace Sitecore.Web
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
protected void Application_BeginRequest()
{
Sitecore.Context.Items["Disable"] = new VersionCountDisabler();
}
}
}
My /App_Start/BundleConfig.cs file:
using System.Web.Optimization;
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/scripts/footer").Include(
"~/Assets/js/jquery.validate.js",
"~/Assets/js/additional-methods.js",
"~/Assets/js/form.js",
"~/Assets/js/marketo.js"
));
#if DEBUG
BundleTable.EnableOptimizations = false;
#else
BundleTable.EnableOptimizations = true;
#endif
}
}
The <system.webServer>/modules section of my /Web.config:
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
<add type="Sitecore.Web.RewriteModule, Sitecore.Kernel" name="SitecoreRewriteModule" />
<add type="Sitecore.Nexus.Web.HttpModule,Sitecore.Nexus" name="SitecoreHttpModule" />
<add type="Sitecore.Resources.Media.UploadWatcher, Sitecore.Kernel" name="SitecoreUploadWatcher" />
<add type="Sitecore.IO.XslWatcher, Sitecore.Kernel" name="SitecoreXslWatcher" />
<add type="Sitecore.IO.LayoutWatcher, Sitecore.Kernel" name="SitecoreLayoutWatcher" />
<add type="Sitecore.Configuration.ConfigWatcher, Sitecore.Kernel" name="SitecoreConfigWatcher" />
<remove name="Session" />
<add name="Session" type="System.Web.SessionState.SessionStateModule" preCondition="" />
<add type="Sitecore.Analytics.RobotDetection.Media.MediaRequestSessionModule, Sitecore.Analytics.RobotDetection" name="MediaRequestSessionModule" />
<add type="Sitecore.Web.HttpModule,Sitecore.Kernel" name="SitecoreHttpModuleExtensions" />
<add name="SitecoreAntiCSRF" type="Sitecore.Security.AntiCsrf.SitecoreAntiCsrfModule, Sitecore.Security.AntiCsrf" />
<remove name="BundleModule"/>
<add type="System.Web.Optimization.BundleModule" name="BundleModule"/>
</modules>
And lastly, the IgnoreUrlPrefixes setting as displayed by /sitecore/admin/showconfig.aspx that shows /bundles is included in the list:
<!--
IGNORE URLS
Set IgnoreUrlPrefixes to a '|' separated list of url prefixes that should not be
regarded and processed as friendly urls (ie. forms etc.)
-->
<setting name="IgnoreUrlPrefixes" value="/sitecore/default.aspx|/trace.axd|/webresource.axd|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.DialogHandler.aspx|/sitecore/shell/applications/content manager/telerik.web.ui.dialoghandler.aspx|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.SpellCheckHandler.axd|/Telerik.Web.UI.WebResource.axd|/sitecore/admin/upgrade/|/layouts/testing|/bundles|/Assets"/>
UPDATE: See accepted answer below.
I discovered what the issue was. The "inherits" attribute of the markup of my Global.asax did not match the class name in the Global.asax.cs.
Time to experiment:
Remove your compiler directives. <compilation debug="true|false"> should control that at runtime.
Remove your web.config <module> entries. I've found this hasn't been necessary for even Sitecore 7.2 projects.

unable to load template file using spring and tile integration

I am new to Apache tiles, trying to configure it in spring 4. But the templates, i am extending is not visible in my jsp page.For ex: If i am hitting url "/admin", then content of admin.jsp is visible, nothing else.
blow is the code snippet.
application-context.xml
<beans:bean id="viewResolver"
class="org.springframework.web.servlet.view.tiles3.TilesViewResolver" />
<beans:bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<beans:property name="definitions">
<beans:list>
<beans:value>/WEB-INF/layouts/views.xml</beans:value>
</beans:list>
</beans:property>
</beans:bean>
views.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
"http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
<definition name="DefaultTemplate"
template="/WEB-INF/views/template/SiteTemplate.jsp">
<put-attribute name="title" value="Home" />
<put-attribute name="header" value="/WEB-INF/views/template/header.jsp" />
<put-attribute name="body" value="This is body" />
<put-attribute name="footer" value="/WEB-INF/views/template/footer.jsp" />
</definition>
<definition name="admin" extends="DefaultTemplate">
<put-attribute name="body"
value="/WEB-INF/views/admin.jsp" />
</definition>
</tiles-definitions>
SiteTemplate.jsp
<%# taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>DCAT</title>
</head>
<body>
<div>
<!-- Header -->
<tiles:insertAttribute name="header" />
<!-- Body Page -->
<div>
<tiles:insertAttribute name="body" />
</div>
<!-- Footer Page -->
<tiles:insertAttribute name="footer" />
</div>
</body>
</html>
Footer.jsp
<div>
<h2>Footer</h2>
</div>
Header.jsp
<div>
<h2>Header</h2>
</div>
admin.jsp
<div style="margin:10px;">
<h3>SpringMVC - Tiles3 Integration</h3>
<p>By:- Thita Nayak</p>
</div>
Admin controller
#Controller
public class AdminController {
private static final Logger logger = LoggerFactory.getLogger(AdminController.class);
#RequestMapping(value = "/admin", method = RequestMethod.GET)
public String admin(){
return "admin";
}
}
I cannot see anything wrong with your code
The problem might be in the namespace declaration
Try to change beans:bean to beans if your namespace is as follow
<beans xmlns="http://www.springframework.org/schema/beans" ...

JSF/Primefaces How to include an .xhtml from another domain into your .xhtml

I am trying to include an xhtml which is on another domain (on the same server) inside my .xhtml.
The sample code is the following
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<h:outputStylesheet library="css" name="style.css" target="body" />
</h:head>
<h:body>
<p:layout id="page" fullPage="true">
<!-- North -->
<p:layoutUnit position="north" size="10%"
style="border: none !important">
</p:layoutUnit>
<!-- South -->
<p:layoutUnit position="south" size="5%" collapsible="true" gutter="0">
<h:outputText value="South unit Content." />
</p:layoutUnit>
<!-- West -->
<p:layoutUnit position="west" size="200" header="Menu"
collapsible="true" effect="slide" styleClass="menuBar">
<h:form id="form1">
<p:panelMenu>
<p:submenu label="Students">
<p:menuitem value="page1" update=":centerpanel"
actionListener="#{layoutController.setNavigation('page2.xhtml')}" />
<p:menuitem value="page2" update=":centerpanel"
actionListener="#{layoutController.setNavigation('http://localhost:8080/externalsite/newpage.xhtml')}" />
</p:submenu>
</p:panelMenu>
</h:form>
</p:layoutUnit>
<!-- Center -->
<p:layoutUnit id="center" position="center">
<h:panelGroup id="centerpanel" layout="block">
<ui:include id="include" src="#{layoutController.navigation}" />
</h:panelGroup>
</p:layoutUnit>
</p:layout>
</h:body>
</html>
So basically in the center layout unit I am trying to include the external .xhtml (which is on the same domain however).
JSF templates can be included only, if they are available within the same classloader.
If you want to embed an external page into your page, you need to user iframe.
For example:
<iframe src="http://www.primefaces.org/showcase/ui/home.jsf"/>
allows you to embed PrimeFaces showcase withing your page.
This is not possible. With the ui:include Tag you can only include Code Snippets from other xhtml files. What you are trying to do is accessing Code from another domain, but what you see in the final web app is only the generated HTML and Javascript Code. You cannot work with that in your application, as you have no access to the sourcecode.

Facelets: any library that ships templates?

Like in the title, is there any lib like PrimeFaces or RichFaces that is template-oriented?
I'm building my own including some fixed/liquid/elastic base layouts but I wonder if someone out there has already done this boring work.
UPDATE
i'm sorry, i haven't explained myself.
i'm talking about a sort of framework on framework made by a tree of templates (and optionally beans).
i'm currently using this root template, that is bundled in a jar file with some bean and , entity, for all my applications:
<!DOCTYPE html>
<html lang="#{localeBean.locale.language}"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui"
xmlns:o="http://omnifaces.org/ui"
xmlns:s="http://shapeitalia.com/jsf2"
xmlns:sc="http://java.sun.com/jsf/composite/shape">
<f:view locale="#{localeBean.locale}">
<h:head>
<title><ui:insert name="module"/> - <ui:insert name="title"/></title>
<link rel="shortcut icon" type="image/x-icon" href="#{resource['shape/favicon/shape.ico']}" />
<h:outputStylesheet library="shape" name="css/core.css" />
<h:outputStylesheet library="shape" name="css/fileicons.css" />
<h:outputScript library="shape" name="js/jquery.jsPlumb-1.3.15-all.js" />
<h:outputScript library="shape" name="js/core.js" />
</h:head>
<h:body>
<ui:debug hotkey="x" />
<p:growl id="messages" globalOnly="false" autoUpdate="true" showDetail="true" showSummary="true" />
<p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();" />
<p:dialog modal="true" widgetVar="statusDialog" header="loading..." resizable="false" closable="false">
<h:graphicImage library="shape" name="images/ajaxloadingbar.gif" />
</p:dialog>
<div>
<ui:insert name="header">
<h:form>
<s:panelGrid cellStyle="border: 0;">
<s:column style="text-align: left;">
<p:commandLink action="index" >
<h:graphicImage library="shape" name="images/shape.png" height="30px" style="vertical-align: middle; float: left; border: 0"/>
</p:commandLink>
</s:column>
<s:column style="text-align: right;">
<p:menuButton rendered="#{not empty request.userPrincipal}" value="#{request.userPrincipal.name}" style="float: right">
<p:menuitem actionListener="#{sessionBean.logout}" action="index" ajax="false" icon="ui-icon-power" value="#{bundle.logout}"/>
</p:menuButton>
</s:column>
</s:panelGrid>
</h:form>
</ui:insert>
</div>
<h:panelGroup rendered="#{not empty request.userPrincipal}">
<ui:insert name="content">insert content here</ui:insert>
</h:panelGroup>
<h:panelGroup rendered="#{empty request.userPrincipal}">
<h:form>
<p:panel header="login">
<h:panelGrid columns="3">
<h:outputLabel for="login_email" value="Email:" />
<h:outputLabel for="login_password" value="Password:" />
<h:panelGroup />
<p:inputText id="login_email" value="#{requestScope.email}" label="email" size="32"/>
<p:password id="login_password" value="#{requestScope.password}" label="password" feedback="false" size="32"/>
<p:commandButton value="Login" action="#{sessionBean.login}" icon="ui-icon ui-icon-check" ajax="false"/>
<p:message for="login_email" />
<p:message for="login_password" />
<h:panelGroup />
</h:panelGrid>
</p:panel>
</h:form>
</h:panelGroup>
<ui:insert name="external" />
</h:body>
</f:view>
</html>
and this is only the root one.
i'd like to know if is there someone who has already done a work like this and have bundled it
ok there is no such a thing.
the best out there are components like p:layout.

JSF/PrimeFaces - Template with <p:layout>

I need to create a layout like this but with all the containers on separated files, like:
top.xhtml
<p:layout fullPage="true">
<p:layoutUnit position="north" header="#{support.applicationTitle}">
<h:form>
<p:menubar>
<p:menuitem value="Quit" icon="ui-icon-close" action="#{userController.logOut()}" />
</p:menubar>
</h:form>
</p:layoutUnit>
Without the </p:layout> because it will be close on my footer.xhtml like:
<p:layoutUnit position="south" header="© 2012 - 2012 PORTAL DE IDEIAS">
</p:layoutUnit></p:layout>
I have tried with both files but I get a error telling me that I need to close the layout tag, what is correct, but how can I solve my problem? Is this the best approach for a template? And another problem is that the layout tag require a center layoutUnit
This is indeed not the right approach. Your template has to be XML well formed. I suggest to create a master template file instead if all you want is to only specify the center unit.
Taking the example on the showcase site, that should look like this:
/WEB-INF/templates/layout.xhtml
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
>
<h:head>
<title>Title</title>
</h:head>
<h:body>
<p:layout fullPage="true">
<p:layoutUnit position="north" size="100" header="Top" resizable="true" closable="true" collapsible="true">
<h:outputText value="Top unit content." />
</p:layoutUnit>
<p:layoutUnit position="south" size="100" header="Bottom" resizable="true" closable="true" collapsible="true">
<h:outputText value="South unit content." />
</p:layoutUnit>
<p:layoutUnit position="west" size="200" header="Left" resizable="true" closable="true" collapsible="true">
<h:form>
<ui:include src="../templates/themeMenu.xhtml" />
</h:form>
</p:layoutUnit>
<p:layoutUnit position="east" size="200" header="Right" resizable="true" closable="true" collapsible="true" effect="drop">
<h:outputText value="Right unit content." />
</p:layoutUnit>
<p:layoutUnit position="center">
<ui:insert name="content">Put default content here, if any.</ui:insert>
</p:layoutUnit>
</p:layout>
</h:body>
</html>
Note the <ui:insert> in the center unit.
The template client can then just look like this:
/page.xhtml
<ui:composition template="/WEB-INF/templates/layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
>
<ui:define name="content">
<p>Here goes your view-specific content.</p>
</ui:define>
</ui:composition>
which you open by http://example.com/contextname/page.xhtml.
See also:
How to include another XHTML in XHTML using JSF 2.0 Facelets?
If you're looking for live open source examples of advanced Facelets templating, you may find OmniFaces showcase app useful.