I'm currently working on a page that is made with openui5, what I need to do is to insert a captcha, but as far as I know there is no captcha in openui5, what I was trying is to insert HTML content into this.
The problem is, my views are in XML and I did try to insert directly using tags and changing the content, but wasn't possible, it says incorrect xml parsing.
Part of my code of where I want to input my html div:
<Page id="page1" class="marginBoxContent" showHeader="false" showFooter="false" enableScrolling="true">
<content>
<Image src="../../image/logo.svg" />
<l:Grid
defaultSpan="L12 M12 S12"
width="100%">
<l:content>
<f:Form id="FormChange354"
minWidth="1024"
maxContainerCols="2"
editable="true">
<f:layout>
<f:ResponsiveGridLayout
labelSpanL="3"
labelSpanM="3"
emptySpanL="4"
emptySpanM="4"
columnsL="1"
columnsM="1" />
</f:layout>
<f:formContainers>
<f:FormContainer>
<f:formElements>
<f:FormElement label="{i18n>Language}">
<f:fields>
<Select id="animationSelect" selectedKey="en" change="languageChange">
<core:Item text="English" key="en" />
<core:Item text="Português" key="pt" />
<core:Item text="Español" key="es" />
<layoutData>
<FlexItemData growFactor="1" />
</layoutData>
</Select>
</f:fields>
</f:FormElement>
</f:formElements>
<f:formElements>
<f:FormElement label="{i18n>User}">
<f:fields>
<Input id="username" value="" type="Email" />
</f:fields>
</f:FormElement>
</f:formElements>
<f:formElements>
<f:FormElement label="{i18n>Password}">
<f:fields>
<Input id="password" type="Password" placeholder="" value="" />
</f:fields>
</f:FormElement>
</f:formElements>
<f:formElements>
<f:FormElement label="">
<f:fields>
<Button id="btnLogin" text="{i18n>Sigin}" type="Emphasized" press="login" />
</f:fields>
</f:FormElement>
</f:formElements>
</f:FormContainer>
</f:formContainers>
</f:Form>
<l:VerticalLayout>
<Link text="{i18n>CreateUser}" press="navCreateUser" />
<Link text="{i18n>RecoverPass}" press="navRecoverPass" />
<Link text="{i18n>ChangePass}" press="navChangePass" />
</l:VerticalLayout>
</l:content>
</l:Grid>
</content>
I want to insert exaclty here:
<f:formElements>
<f:FormElement label="">
<f:fields>
<Button id="btnLogin" text="{i18n>Sigin}" type="Emphasized" press="login" />
</f:fields>
</f:FormElement>
</f:formElements>
Inside the fields xml or before, because the captcha will appear above the login button.
The content of the div I want to insert is from google captcha:
<div id='recaptcha' class="g-recaptcha"
data-sitekey="your_site_key"
data-callback="onSubmit"
data-size="invisible"></div>
Couldn't have success yet, anybody can help me with that?
Maybe is something about the namespace, I don't know, here is my namespace config:
<mvc:View
height="100%"
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form"
xmlns:core="sap.ui.core"
controllerName="hiddenName.app.login.view.Login">
Thanks a lot for your time!
thank you for every help. I got some help from all comments, what I did was declare the namespace to html:
<mvc:View
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form"
xmlns:core="sap.ui.core"
xmlns:html="http://www.w3.org/1999/xhtml"
height="100%"
controllerName="hiddenName.app.login.view.Login"
>
And simply added the tag as I show down here:
<html:div id="recaptchaGoogle" class="g-recaptcha" data-sitekey="yourKey"></html:div>
Also remember to declare the import of the google js(added it on my index):
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
I'm still trying to figure out how to get this captcha answer and pass or not to the login.
With that, the captcha appears and is generated.
Thank you!
To insert HTML in a XML view you could use the HTML control from the sap.ui.core library. You will have to escape the HTML text before using it in XML.
<core:HTML content='<div id="recaptcha" class="g-recaptcha" data-sitekey="your_site_key" data-callback="onSubmit" data-size="invisible"></div>' />
Related
I am using a Wizard object in my app with multiple steps. I want the content of this step to utilize the full width available. I am currently using the below XML, though this is just resulting in the content being bunched together on the left (see attached image).
How can I modify this so the SimpleForms will use the full width of the page ?
Any help would be greatly appreciated,
thanks,
Joe
<WizardStep id="wizStep2" validated="true" title="Customer Confirm"
icon="sap-icon://customer" >
<HBox width="100%" fitContainer="true">
<form:SimpleForm editable="true">
<Label text="Title"/>
<Input value="MR"/>
<Label text="Name"/>
<Input value="John"/>
<Input value="Smith"/>
<Label text="House"/>
<Input value="81"/>
<Label text="Street"/>
<Input value="Main Road"/>
<Label text="City"/>
<Input value=""/>
<Label text="PostCode"/>
<Input value=""/>
</form:SimpleForm>
<form:SimpleForm editable="true">
<Label text="Home Tel"/>
<Input value=""/>
<Label text="Mobile No"/>
<Input value=""/>
<Label text="Email"/>
<Input value=""/>
</form:SimpleForm>
</HBox>
</WizardStep>
Current output
A SimpleForm will start a new column if you use a Title element: Simple Form API Doc. You also can control the Layout of the Simple Form by using SimpleFormLayout.
So basically, you need to place content that will actually use the 100% width.
By default it uses 100% with ... your limitation comes from somewhere else in your view.
This wizard takes 100% of your screen:
<mvc:View controllerName="tc_v1.test.controller.Main" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc"
displayBlock="true" xmlns="sap.m" xmlns:form="sap.ui.layout.form">
<App id="idAppControl">
<pages>
<Page title="{i18n>title}">
<content>
<Wizard id="wizard" complete="onPressReview" finishButtonText="Review" showNextButton="true">
<WizardStep id="wizStep1" validated="true" title="Customer Confirm" icon="sap-icon://customer">
<HBox fitContainer="true">
<form:SimpleForm editable="true">
<Label text="Title"/>
<Input value="MR"/>
<Label text="Name"/>
<Input value="John"/>
<Input value="Smith"/>
<Label text="House"/>
<Input value="81"/>
<Label text="Street"/>
<Input value="Main Road"/>
<Label text="City"/>
<Input value=""/>
<Label text="PostCode"/>
<Input value=""/>
</form:SimpleForm>
<form:SimpleForm editable="true">
<Label text="Home Tel"/>
<Input value=""/>
<Label text="Mobile No"/>
<Input value=""/>
<Label text="Email"/>
<Input value=""/>
</form:SimpleForm>
</HBox>
</WizardStep>
<WizardStep id="id_wizStp2" validated="true" title="Step 2"/>
<WizardStep id="id_wizStp3" validated="true" title="Step 3"/>
</Wizard>
</content>
</Page>
</pages>
</App>
</mvc:View>
I'm trying to add 2 Input controls to my Toolbar with Title. But in OverflowToolbar they go to overflow area and in Toolbar control are not moved to the right side by ToolbarSpacer. How do I make this work as expected?
<Table
id="sfcTable"
mode="MultiSelect"
items="{path: 'sfcTable>/Rowsets/Rowset/0/Row', sorter: { path: 'Shop Order'}}">
<headerToolbar>
<OverflowToolbar>
<Title
text="Table Header Here"
level="H1" />
<ToolbarSpacer />
<Input
id="operationDelay"
maxLength="6"
type="Number"
description="ms"
fieldWidth="5rem">
<layoutData>
<OverflowToolbarLayoutData
priority="NeverOverflow" />
</layoutData>
</Input>
<Input
id="actionDelay"
maxLength="6"
type="Number"
description="ms"
fieldWidth="5rem">
<layoutData>
<OverflowToolbarLayoutData
priority="NeverOverflow" />
</layoutData>
</Input>
</OverflowToolbar>
</headerToolbar>
...
</Table>
OverflowToolbar image
Note that only one Input is shown.
Toolbar code:
<Table
id="sfcTable"
mode="MultiSelect"
items="{path: 'sfcTable>/Rowsets/Rowset/0/Row', sorter: { path: 'Shop Order'}}">
<headerToolbar>
<Toolbar>
<Title
text="Table Header Here"
level="H1" />
<ToolbarSpacer />
<Input
id="operationDelay"
maxLength="6"
type="Number"
description="ms"
fieldWidth="5rem">
</Input>
<Input
id="actionDelay"
maxLength="6"
type="Number"
description="ms"
fieldWidth="5rem">
</Input>
</Toolbar>
</headerToolbar>
Toolbar image
I also had the same problem at some point and ended up with wrapping the additional controls into a nested Toolbar. See working example in snippet below or at JSBin: http://jsbin.com/hofuvum/edit?html,output
<!DOCTYPE html>
<html><head>
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<title>JSFragment used in XmlView</title>
<!-- Load UI5, select Blue Crystal theme and the "commons" control library -->
<script id='sap-ui-bootstrap' type='text/javascript'
src='https://openui5.hana.ondemand.com/resources/sap-ui-core.js'
data-sap-ui-theme='sap_bluecrystal'
data-sap-ui-libs='sap.m, sap.ui.commons'></script>
<!-- DEFINE RE-USE COMPONENTS - NORMALLY DONE IN SEPARATE FILES -->
<!-- define an XMLView - normally done in a separate file -->
<script id="view1" type="sapui5/xmlview">
<mvc:View xmlns:core="sap.ui.core" xmlns:layout="sap.ui.commons.layout" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="my.own.controller" xmlns:html="http://www.w3.org/1999/xhtml">
<OverflowToolbar>
<Title
text="Table Header Here"
level="H1" />
<ToolbarSpacer />
<Toolbar>
<Input
id="operationDelay"
maxLength="6"
type="Number"
description="ms"
fieldWidth="5rem">
</Input>
<Input
id="actionDelay"
maxLength="6"
type="Number"
description="ms"
fieldWidth="5rem">
</Input>
</Toolbar>
</OverflowToolbar>
</mvc:View>
</script>
<script>
// define a new (simple) Controller type
sap.ui.controller("my.own.controller", {
});
/*** THIS IS THE "APPLICATION" CODE ***/
// instantiate the View
var myView = sap.ui.xmlview("myView", {viewContent:jQuery('#view1').html()}); // accessing the HTML inside the script tag above
// put the View onto the screen
myView.placeAt('content');
</script>
</head>
<body class='sapUiBody'>
<div id='content'></div>
</body>
</html>
The problem is how you apply fieldWidth...
Here is working example based on your code: https://jsbin.com/pivodos/edit?html,output
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>SAPUI5 single file template | nabisoft</title>
<script
src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-theme="sap_belize"
data-sap-ui-libs="sap.m"
data-sap-ui-compatVersion="edge"
data-sap-ui-preload="async"></script>
<!-- XMLView -->
<script id="myXmlView" type="ui5/xmlview">
<mvc:View
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc">
<Table>
<headerToolbar>
<OverflowToolbar>
<Title text="Table with OverflowToolbar" level="H1" />
<ToolbarSpacer />
<Input
maxLength="6"
type="Number"
description="ms"
width="10rem"
fieldWidth="50%">
<layoutData>
<OverflowToolbarLayoutData priority="NeverOverflow" />
</layoutData>
</Input>
<Input
maxLength="6"
type="Number"
description="ms"
width="10rem"
fieldWidth="50%">
<layoutData>
<OverflowToolbarLayoutData priority="NeverOverflow" />
</layoutData>
</Input>
</OverflowToolbar>
</headerToolbar>
</Table>
<Table>
<headerToolbar>
<Toolbar>
<Title text="Table with Toolbar" level="H1" />
<ToolbarSpacer />
<Input
maxLength="6"
type="Number"
description="ms"
width="10rem"
fieldWidth="50%">
</Input>
<Input
maxLength="6"
type="Number"
description="ms"
width="10rem"
fieldWidth="50%">
</Input>
</Toolbar>
</headerToolbar>
</Table>
</mvc:View>
</script>
<script>
sap.ui.getCore().attachInit(function () {
"use strict";
//### 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>
Mockup
Current Code
<mvc:View
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form"
displayBlock="true" height="100%">
<Page showHeader="false" id="page">
<content>
<l:Grid defaultSpan="L12 M12 S12" width="auto">
<l:content>
<f:Form editable="true">
<f:title>
<core:Title text="Test" />
</f:title>
<f:layout>
<f:ResponsiveGridLayout
labelSpanL="3"
labelSpanM="3"
emptySpanL="4"
emptySpanM="4"
columnsL="1"
columnsM="1"
/>
</f:layout>
<f:formContainers>
<f:FormContainer>
<f:formElements>
<f:FormElement label="Name">
<f:fields>
<Input id="name1" value="" />
</f:fields>
</f:FormElement>
<f:FormElement label="Name">
<f:fields>
<Input id="name2" value="" />
</f:fields>
</f:FormElement>
<f:FormElement>
<f:fields>
<CheckBox id="cb1" />
<Text wrapping="true" text="lorem ipsum" />
</f:fields>
</f:FormElement>
</f:formElements>
</f:FormContainer>
</f:formContainers>
</f:Form>
</l:content>
</l:Grid>
</content>
</Page>
</mvc:View>
Problem
The checkbox is not centered. The current code is responsive and the solution should also be responsive.
If you want the checkbox to be centered you need to use a label on your formElement just as you do with the others. If you don't want a label you will probably need some css to put a left-margin on that specific FormElement.
There is maybe another way more "polite" to do that, but if it exists I do not know it, will keep looking at that post to see if someone actually offers a better solution.
But for now, I hope this works for you for the moment.
I already create view : header, content, and footer but footer and content not display and not getting an error. the directory in form1.view.xml is correct because no error when I load the form1 view. when I command the header code and I refresh, the content show and footer still not show. when I command the header and content, the footer show. how to fix this problem?
Form1.view.xml
<App id="navCon"
class="footer-height footer-color header-color background-home background-color
footer-size-color panel-header">
<!-- Header -->
<mvc:XMLView viewName="sap.ui.taspen.taspen.Header" />
<App>
<pages>
<Page>
<Panel id="panelModule" headerText="Header form" class="panelForm">
<content>
<Label text="Ini form 1" />
</content>
</Panel>
</Page>
</pages>
</App>
<!-- Footer -->
<mvc:XMLView viewName="sap.ui.taspen.taspen.Footer" />
</App>
Header:
<mvc:View xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" xmlns:t="sap.ui.table" xmlns:l="sap.ui.layout" xmlns:tnt="sap.tnt"
controllerName="sap.ui.taspen.taspen.Header" xmlns:html="http://www.w3.org/1999/xhtml">
<App>
<pages>
<Page showHeader="false">
<tnt:ToolHeader>
<html:img src="icon/logo_taspen.png" class="header-logo-taspen" />
<html:p class="text-header">NEW APPLICATION CORE BUSINESS</html:p>
<ToolbarSpacer width="20px" />
<tnt:ToolHeaderUtilitySeparator />
<ToolbarSpacer>
<layoutData>
<OverflowToolbarLayoutData priority="NeverOverflow"
minWidth="20px" />
</layoutData>
</ToolbarSpacer>
<Text text="Selasa, 21/4/2017 / 11:07 AM" class="text-white" />
<Text text="Hello, Jhon Doe" class="text-white">
<layoutData>
<OverflowToolbarLayoutData priority="NeverOverflow" />
</layoutData>
</Text>
<Button icon="sap-icon://log" type="Reject" press="logoutPress"
class="button-logout button-logout-icon margin-logout">
<layoutData>
<OverflowToolbarLayoutData priority="NeverOverflow" />
</layoutData>
</Button>
</tnt:ToolHeader>
</Page>
</pages>
</App>
</mvc:View>
Footer:
<mvc:View xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" xmlns:t="sap.ui.table" xmlns:l="sap.ui.layout" xmlns:tnt="sap.tnt"
controllerName="sap.ui.taspen.taspen.Footer" xmlns:html="http://www.w3.org/1999/xhtml">
<App>
<Page showHeader="false">
<footer>
<OverflowToolbar id="otbFooter">
<Button type="Transparent" text="Kebijakan dan Privasi"
press="kebdanprivPress" />
<Button type="Transparent" text="Bantuan" press="bantuanPress" />
<ToolbarSpacer />
<Label text="All Rights Reserved PT. Taspen Persero" />
<html:img src="icon/copyright-symbol.png" class="footer-logo-copyright" />
<Label text="2018" />
</OverflowToolbar>
</footer>
</Page>
</App>
</mvc:View>
To Display custome header instead of page header you have to use
<customHeader></customHeader>
tag.and remaining you have to place in <content></content>tag. can see you are missing content tag.
I am developing an application using sapui5 and I am having a problem with the sizing of the "dropdownbox" in simple form. The items from sap.m package seem to automatically adjust to the size of the simple form content, while other items from packages like sa.ui.commons dont adjust as well.
How do I adjust the size of the dropdownbox? I tried setting the width and the height to "100%" but that did not work.
Adding the code:
<c:FragmentDefinition
xmlns:mvc="sap.ui.core.mvc"
xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form"
xmlns:c="sap.ui.core"
xmlns:co="sap.ui.commons"
xmlns:col="sap.ui.commons.layout"
xmlns="sap.m">
<l:Grid
defaultSpan="L12 M12 S12"
width="auto">
<l:content>
<f:SimpleForm
minWidth="800"
maxContainerCols="2"
editable="true"
layout="ResponsiveGridLayout"
title="General Info"
labelSpanL="3"
labelSpanM="3"
emptySpanL="4"
emptySpanM="4"
columnsL="2"
columnsM="2"
class="editableForm">
<f:content>
<Label text="Employee Name" />
<co:DropdownBox width="200px" >
<c:ListItem text="Emp1"/>
<c:ListItem text="Emp2"/>
</co:DropdownBox>
<Label text="Type of Travel" />
<Select >
<c:ListItem key="B" text="Business"/>
<c:ListItem key="O" text="Other"/>
</Select>
</f:content>
</f:SimpleForm>
</l:content>
</l:Grid>
</c:FragmentDefinition>
How about just omitting the width of the commons control, just as you did with the m control? That scales the sap.ui.commons.DropdownBox just as wide as the sap.m.Select control.
On a sidenote, I would not mix m controls with common controls; you may run into CSS issues
EDIT: See this working example, both sap.ui.commons.DropdownBox and sap.m.Select are of equal size:
sap.ui.controller("view1.initial", {
onInit : function() { }
});
var app = new sap.m.App({});
var oView = sap.ui.xmlview({
viewContent: jQuery("#view1").html()
});
app.addPage(oView);
app.placeAt("uiArea");
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<title>SAPUI5 template</title>
<script id="sap-ui-bootstrap"
src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-libs="sap.m"></script>
<script id="view1" type="ui5/xmlview">
<mvc:View
controllerName="view1.initial"
xmlns:mvc="sap.ui.core.mvc"
xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form"
xmlns:c="sap.ui.core"
xmlns:co="sap.ui.commons"
xmlns:col="sap.ui.commons.layout"
xmlns="sap.m">
<l:Grid
defaultSpan="L12 M12 S12"
width="auto">
<l:content>
<f:SimpleForm
minWidth="800"
maxContainerCols="2"
editable="true"
layout="ResponsiveGridLayout"
title="General Info"
labelSpanL="3"
labelSpanM="3"
emptySpanL="4"
emptySpanM="4"
columnsL="2"
columnsM="2"
class="editableForm">
<f:content>
<Label text="Employee Name" />
<co:DropdownBox>
<c:ListItem text="Emp1"/>
<c:ListItem text="Emp2"/>
</co:DropdownBox>
<Label text="Type of Travel" />
<Select>
<c:ListItem key="B" text="Business"/>
<c:ListItem key="O" text="Other"/>
</Select>
</f:content>
</f:SimpleForm>
</l:content>
</l:Grid>
</mvc:View>
</script>
</head>
<body class="sapUiBody" role="application">
<div id="uiArea"></div>
</body>
</html>