Guest User

Untitled

a guest
Oct 26th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.49 KB | None | 0 0
  1. <core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:l="sap.ui.layout" xmlns:f="sap.ui.layout.form"
  2. controllerName="view.login" xmlns:html="http://www.w3.org/1999/xhtml" >
  3. <Page title="WEBAPP">
  4. <content>
  5.  
  6. <FlexBox
  7. alignItems="Center"
  8. justifyContent="Center">
  9. <items>
  10. <Image src="general/img/logo.png" width="{/widthL}"/>
  11. </items>
  12. </FlexBox>
  13.  
  14. <FlexBox
  15. alignItems="Center"
  16. justifyContent="Center">
  17. <items>
  18.  
  19. <l:Grid
  20. defaultSpan="L12 M12 S12"
  21. width="auto">
  22. <l:content>
  23. <f:Form id="loginForm"
  24. minWidth="1024"
  25. maxContainerCols="2"
  26. editable="true">
  27. <f:title>
  28. <core:Title text="" />
  29. </f:title>
  30. <f:layout>
  31. <f:ResponsiveGridLayout
  32. labelSpanL="3"
  33. labelSpanM="3"
  34. emptySpanL="4"
  35. emptySpanM="4"
  36. columnsL="1"
  37. columnsM="1" />
  38. </f:layout>
  39. <f:formContainers>
  40. <f:FormContainer>
  41. <f:formElements>
  42. <f:FormElement label="Username">
  43. <f:fields>
  44. <Input id="id_inputUsername" />
  45. </f:fields>
  46. </f:FormElement>
  47. <f:FormElement label="Password">
  48. <f:fields>
  49. <Input id="id_inputPassword" type="Password" />
  50. </f:fields>
  51. </f:FormElement>
  52. </f:formElements>
  53. </f:FormContainer>
  54. </f:formContainers>
  55. </f:Form>
  56. </l:content>
  57. </l:Grid>
  58.  
  59.  
  60. </items>
  61. </FlexBox>
  62.  
  63.  
  64. </content>
  65. <footer>
  66. <Bar>
  67. <contentRight>
  68. <Button id="idButtonLogin" text="Login" type="Emphasized" visible="true" press="handleFooterBarButtonPress" icon="sap-icon://accept" />
  69. </contentRight>
  70. </Bar>
  71. </footer>
  72. </Page>
  73. </core:View>
  74.  
  75. <Input id="id_inputPassword"
  76. type="Password"
  77. change="onPasswordChange" />
  78.  
  79. ...
  80.  
  81. <Button id="idButtonLogin"
  82. text="Login"
  83. type="Emphasized"
  84. visible="true"
  85. press="handleFooterBarButtonPress"
  86. icon="sap-icon://accept" />
  87.  
  88. onPasswordChange : function(oEvent) {
  89. this.getView().byId("idButtonLogin").firePress();
  90. },
  91.  
  92. handleFooterBarButtonPress : function(oEvent) {
  93. jQuery.sap.require("sap.m.MessageToast");
  94. sap.m.MessageToast.show("Login!");
  95. }
  96.  
  97. $('#id_inputPassword').on('keydown',function(e){
  98. e.stopPropagation();
  99. if (e.keyCode == 13)
  100. {
  101. $('#formLogin').submit();
  102. }
  103. });
  104.  
  105. sap.ui.getCore().byId("inputUserName").attachBrowserEvent('keyup', function(e) {
  106. if (e.which == 13 || e.keyCode == 13) {
  107. var userName = sap.ui.getCore().byId("inputUserName").getValue();
  108. var password = sap.ui.getCore().byId("inputPassword").getValue();
  109. if (userName.length == 0) {
  110. sap.ui.getCore().byId('inputUserName').setValueState('Error');
  111. sap.ui.getCore().byId('inputUserName').focus();
  112. } else if (password.length == 0) {
  113. sap.ui.getCore().byId('inputPassword').setValueState('Error');
  114. sap.ui.getCore().byId('inputPassword').focus();
  115. } else if (userName.length > 0 && password.length > 0) {
  116. //YOUR LOGIC
  117. }
  118. }
  119. });
  120.  
  121.  
  122. //another way by using sap's default saponenter function
  123. sap.ui.getCore().byId("inputPassword").onsapenter = function(e) {
  124. var userName = sap.ui.getCore().byId("inputUserName").getValue();
  125. var password = sap.ui.getCore().byId("inputPassword").getValue();
  126. if (userName.length == 0) {
  127. sap.ui.getCore().byId('inputUserName').setValueState('Error');
  128. sap.ui.getCore().byId('inputUserName').focus();
  129. } else if (password.length == 0) {
  130. sap.ui.getCore().byId('inputPassword').setValueState('Error');
  131. sap.ui.getCore().byId('inputPassword').focus();
  132. } else if (userName.length > 0 && password.length > 0) {
  133. //your logic
  134. }
  135. }
  136.  
  137. $('#idButtonLogin').bind('keydown', function(e) {
  138. if (e.keyCode == 13) {
  139. // Here you can call the function
  140. }
  141. });
Add Comment
Please, Sign In to add comment