Popular New Releases in Model View Controller
spring-framework
v5.3.19
cphalcon
v5.0.0beta3
AspNetCore.Docs
Create a gRPC client and server in ASP.NET Core 3.1
Pokedex
1.0.5
azul
1.0.0-alpha1 release (for Windows-64bit only)
Popular Libraries in Model View Controller
by spring-projects java
47171 Apache-2.0
Spring Framework
by android kotlin
15550 NOASSERTION
A gardening app illustrating Android development best practices with Android Jetpack.
by JessYanCoding java
11771 Apache-2.0
🔥 A low-cost Android screen adaptation solution (今日头条屏幕适配方案终极版,一个极低成本的 Android 屏幕适配方案).
by phalcon php
10560 NOASSERTION
High performance, full-stack PHP framework delivered as a C extension.
by dotnet csharp
10350 NOASSERTION
Documentation for ASP.NET Core
by knockout javascript
9999 NOASSERTION
Knockout makes it easier to create rich, responsive UIs with JavaScript
by KunMinX java
7373
是 难得一见 的 Jetpack MVVM 最佳实践!在 以简驭繁 的代码中,对 视图控制器 乃至 标准化开发模式 形成正确、深入的理解!
by pedrovgs java
6050 Apache-2.0
Sample project created to show some of the best Android practices to work in the Android UI Layer. The UI layer of this project has been implemented using MVP or MVVM (without binding engine) to show how this patterns works. This project is used during the talk "EffectiveAndroidUI".
by antoniolg java
5958
MVP Android Example
Trending New libraries in Model View Controller
by skydoves kotlin
5211 Apache-2.0
🗡️ Pokedex demonstrates modern Android development with Hilt, Material Motion, Coroutines, Flow, Jetpack (Room, ViewModel) based on MVVM architecture.
by MonkSoul csharp
1536 NOASSERTION
让 .NET 开发更简单,更通用,更流行。
by skydoves kotlin
1150 Apache-2.0
🦁 A Disney app using transformation motions based on MVVM (ViewModel, Coroutines, Flow, LiveData, Room, Repository, Koin) architecture.
by DerekYRC java
1147 Apache-2.0
mini-spring是简化版的spring框架,能帮助你快速熟悉spring源码和掌握spring的核心原理。抽取了spring的核心逻辑,代码极度简化,保留spring的核心功能,如IoC和AOP、资源加载器、事件监听器、类型转换、容器扩展点、bean生命周期和作用域、应用上下文等核心功能。
by skydoves kotlin
887 Apache-2.0
❤️ A sample Marvel heroes application based on MVVM (ViewModel, Coroutines, LiveData, Room, Repository, Koin) architecture.
by hi-dhl kotlin
795 Apache-2.0
本仓库致力于建立最全、最新的的 AndroidX Jetpack 相关组件的实践项目 以及组件对应的分析文章(持续更新中)如果对你有帮助,请在右上角 star 一下,感谢
by TaleLin java
679 MIT
🔨 基于SpringBoot的CMS/DMS/管理系统开发框架
by FunkyMuse kotlin
524 GPL-3.0
🛡️ Android security (camera/microphone dots indicators) app using Hilt, Animations, Coroutines, Material, StateFlow, Jetpack (Room, ViewModel, Paging, Security, Biometrics, Start-up) based on MVVM architecture.
by reillychase python
510
Top Authors in Model View Controller
1
44 Libraries
212
2
22 Libraries
114
3
21 Libraries
135
4
20 Libraries
14648
5
18 Libraries
444
6
16 Libraries
157
7
13 Libraries
656
8
11 Libraries
82
9
11 Libraries
562
10
10 Libraries
77
1
44 Libraries
212
2
22 Libraries
114
3
21 Libraries
135
4
20 Libraries
14648
5
18 Libraries
444
6
16 Libraries
157
7
13 Libraries
656
8
11 Libraries
82
9
11 Libraries
562
10
10 Libraries
77
Trending Kits in Model View Controller
Java MVC libraries are a design pattern for developing web applications. It is a popular approach to building web applications and has become the most popular choice over the last decade. Java MVC libraries like blade, nutz, spring-mvc-showcase have been developed to make development easy and flexible. Blade is an open source, lightweight and easy-to-use MVC framework. It is known as a minimalist, highly modular and flexible framework. Nutz is a lightweight, modular and flexible Java MVC web application framework. It is one of the best frameworks for building modern, high performance web applications with a clean architecture and ease of use. Spring MVC is a popular open source Java web application framework for developing Java EE 5/6 applications. It provides support for RESTful web services, session state management and Ajax features along with other features like reactive programming model and Model View Controller (MVC) architecture. The following is a list of the most popular Java MVC libraries.
The use of Python MVC libraries like pythonik, fastapi-mvc-template, oddo-learning, etc. is becoming more and more popular in the world of AI development. The reason behind this trend is that these libraries provide a great deal of flexibility to developers who want to build web applications with modern features. Pythonik is one such library that enables you to build web applications quickly and easily. It supports both Django and Pyramid frameworks with many other features like authentication, authorization, session management, etc. These libraries also help us to handle data and perform operations on it. We can also add new features to our application by using third-party packages which are available in the market. The following is a list of the most popular open source Python MVC libraries:
There are several Ruby MVC libraries that you can use to develop web applications. These libraries help you write code in a modular manner, which makes it easier to maintain and extend the application. Serve is a library for serving HTML, CSS and JavaScript content through Rack. It is a Rack middleware that manages the process of rendering HTML and executing JavaScript on the client side. It can be used in conjunction with rackup or RJS handlers. served is one of the most popular libraries in Ruby community. dry-view is a lightweight, high performance implementation of view helpers in Rails 3 and 4 that provides the same interface as the original ActiveRecord::ViewHelpers but with simple syntax. It supports multiple backends (Rack, Nunjucks, Haml) and plugins like head tag support. dry-view is designed for Rails 3 or higher only but it's still usable as a gem in Rails 2 as well. Check out the list of free, open source Ruby MVC libraries to help you with your projects.
JavaScript MVC libraries are great for building web applications. They help you organize your code into components, separate concerns and create a clear separation of the different parts of your app. JavaScript MVC frameworks are used to build complex applications. They are used for designing, developing and building applications. JavaScript MVC libraries like sails, spine, swarm etc. are used to create web applications using JavaScript. Sails is an open-source framework for building dynamic websites with Node.js. It uses a model-view controller (MVC) pattern, which separates the logic from the view. The framework is built on top of Express and Koa, two popular web application frameworks for Node.js. Sails is one of the most popular JavaScript MVC libraries for Rails apps. It provides a simple way to build full-stack web applications with CoffeeScript and supports many other languages. Spine is another popular JavaScript MVC library which has been used by Facebook and Twitter to build backend services like GraphQL and Node-RED. Swarm is a new open source JavaScript MVC library that has been created by Walmart Labs and NPM (Node Package Manager). It's easy to use, features an intuitive API, and lets you build real-time applications quickly and efficiently. The entire list of open source JavaScript MVC libraries is provided below.
The use of C++ MVC libraries like treefog-framework, CPPWebFramework, qt-mvvm, libevmvc is a great choice for rapid development of web applications. These frameworks are based on the concept of MVC (Model, View and Controller). These frameworks make it easy to develop applications quickly without having to worry about creating your own UI framework or writing your own data access layer. The frameworks handle much of the boilerplate work for you so that you can focus on writing code that solves your problem. TreeFog is an open source multi-platform framework for developing web applications with C++ and Qt5. It is built on top of WebCore library and provides a set of handy web development tools for rapid development of small to medium size web applications. CPPWebFramework is a high performance web framework engine written in C++ that makes it easy to write fast and scalable web applications. The framework is designed to use modern best practices in order to achieve high performance at low costs. Qt-MVVM is based on the MVVM pattern which allows you to decouple your application's UI from its business logic through the use of ViewModels and ViewControllers. This allows you to separate your business logic from your view code so that it can be reused more easily. Full list of the best open source C++ MVC libraries below
The C# MVC library is a framework which helps in creating MVC applications with data binding and dependency injection. It has many built-in components like SignalR, Web API and others. It also provides a whole bunch of utilities to simplify development. Using the C# MVC libraries like Electron.NET, Chromely, serenity brings a lot of benefits to the application development life cycle. The main reason for this is that it requires no third-party dependencies and provides an easy way to build cross-platform apps. Electron is an open-source framework that allows you to build cross-platform desktop apps using HTML5, JavaScript, and CSS3 technology. In short, Electron makes it possible to develop desktop applications using web technologies. Chromely is an open source library which can be used to build cross-platform desktop apps on the basis of Electron. The main advantage of Chromely is that it allows you to write your code once and deploy it on various platforms like Windows, MacOS, Linux etc. The following is a comprehensive list of the best open source C# MVC libraries.
The Go webapp library is a collection of Go MVC libraries that provide a high-level, web-based user interface for developers to build applications faster. The use of Go MVC libraries, such as iris, utron, goku and gowebapp is a great way to get started with web development. Iris is a popular open source framework for developing web applications in Go. It has built-in support for routing, authentication, and other key features. The utron library is an open source toolkit for building modern web applications in Go. It features a simple but powerful template system using HTML5 syntax and CSS styling conventions. Goku is an opinionated MVC framework built on top of play/2.0. It provides a set of tools to build RESTful APIs and also provides support for pub/sub messaging mechanisms such as Kafka or Redis Publish-Subscribe (pubsub) systems like RabbitMQ or ZeroMQ. Gowebapp is a full featured native mobile app development stack that runs on iOS and Android platforms. It includes everything needed to build all aspects of your app from start to finish, including models, views and controllers, routing logic and more! Popular open source Go MVC libraries among developers include
The use of MVC frameworks for PHP development is a matter of choice. There are many ways to approach the problem and each one has its own merits. The use of MVC makes it easy to create multiple applications that share a common set of functionality without having to rewrite them from scratch each time you want to add new features, allowing developers to maintain all their applications in one place. MVC is a common architecture for crafting web applications, but it can be applied in many other scenarios as well. In fact, there are several PHP MVC libraries available for you to use in your next project. WP-MVC is the most popular PHP MVC library around. It's also the first one on this list! WP-MVC comes with a lot of features, like routing, templating and more. PHP-MVC is a great alternative to wp-mvc if you're looking for something more lightweight or want to use some features that wp-mvc doesn't have natively (like routing). This library also supports Laravel 5.* out of the box! Zend_MVC is another great alternative if you're looking for something more lightweight or want to use some features that wp-mvc doesn't have natively (like routing). Many developers depend on the following open source PHP MVC libraries
Trending Discussions on Model View Controller
Multiple submit buttons for post in Javascript/Node/EJS
Few, complex OR many, simple MySQL queries?
Design pattern for Spring Boot back end and Angular front end
I am having trouble using bind to change the this statement to point to my controller Javascript MVC
Value from form input does not be transmit by the submit button. How can I fix that?
How can i deploy my website on Heroku properly?
Send Post request in Node js Rest API
Suggestions on REST API & Software Architecture Style
Preserve Button State When Switching Between View Controllers
Areas, pages, and layouts in .NET Core 3.1
QUESTION
Multiple submit buttons for post in Javascript/Node/EJS
Asked 2022-Mar-30 at 05:16So I'm learning Javascript and one of the things I'm practicing is a model view controller of sorts. Right now I have a form with multiple ejs templates, but only the first one pertains to this question.
The first is Home.ejs
1<DOCTYPE html>
2 <html>
3 <head>
4 <title> HomeTitle </title>
5 <style>
6
7 body{background: skyblue;}
8
9 </style>
10 <body>
11 <p> Welcome Home</p>
12 <div>
13
14 <form id ="redirect" method="POST">
15 <input type="submit"value="SignIn" >
16 <input type="submit" value="Exit" >
17 </form>
18 </body>
19 <script>
20 </script>
21
22 </head>
23 </html>
I also have a router.js that handles as the router file.
1<DOCTYPE html>
2 <html>
3 <head>
4 <title> HomeTitle </title>
5 <style>
6
7 body{background: skyblue;}
8
9 </style>
10 <body>
11 <p> Welcome Home</p>
12 <div>
13
14 <form id ="redirect" method="POST">
15 <input type="submit"value="SignIn" >
16 <input type="submit" value="Exit" >
17 </form>
18 </body>
19 <script>
20 </script>
21
22 </head>
23 </html>// Importing the module
24const express=require("express")
25var bodyParser=require('body-parser')
26
27// Creating express Router
28const router=express.Router()
29var jsonParser= bodyParser.json()
30var urlencodedParser =bodyParser.urlencoded({extended: false});
31// Handling login request
32router.get("/",(req,res,next)=>{
33 res.render('home.ejs')
34})
35
36
37router.post("/", urlencodedParser, function (req,res){
38 return res.redirect("/login");
39})
40
41router.get("/login",(req,res,next)=>{
42 res.render("profile.ejs")
43})
44
45
46router.post("/login", urlencodedParser, function (req,res){
47
48 console.log(req.body)
49 //res.send(req.body.first)
50 return res.redirect('/');
51
52})
53module.exports=router
In my Home.ejs I have two submit buttons, one for signing in, and one for exiting. At present, pressing either button takes me to the sign in page (profile.ejs) I am rendering (b/c there's only one render destination). Is there a way for me to differentiate which button was pressed in the javscript section so that I can chose which page I want to render. For example pressing the Sign In button would render one ejs template, whereas Exit would go to another template that I would render.
The first router.post is the post function where ideally the solution for differentiating would be since that is where I handle rendering the new page based on the post data.
ANSWER
Answered 2022-Mar-30 at 05:16You can assign a name to your inputs:
1<DOCTYPE html>
2 <html>
3 <head>
4 <title> HomeTitle </title>
5 <style>
6
7 body{background: skyblue;}
8
9 </style>
10 <body>
11 <p> Welcome Home</p>
12 <div>
13
14 <form id ="redirect" method="POST">
15 <input type="submit"value="SignIn" >
16 <input type="submit" value="Exit" >
17 </form>
18 </body>
19 <script>
20 </script>
21
22 </head>
23 </html>// Importing the module
24const express=require("express")
25var bodyParser=require('body-parser')
26
27// Creating express Router
28const router=express.Router()
29var jsonParser= bodyParser.json()
30var urlencodedParser =bodyParser.urlencoded({extended: false});
31// Handling login request
32router.get("/",(req,res,next)=>{
33 res.render('home.ejs')
34})
35
36
37router.post("/", urlencodedParser, function (req,res){
38 return res.redirect("/login");
39})
40
41router.get("/login",(req,res,next)=>{
42 res.render("profile.ejs")
43})
44
45
46router.post("/login", urlencodedParser, function (req,res){
47
48 console.log(req.body)
49 //res.send(req.body.first)
50 return res.redirect('/');
51
52})
53module.exports=router<input type="submit" value="SignIn" name="submit">
54<input type="submit" value="Exit" name="submit">
55
Then check the value of submitted input and render/redirect based on that value:
1<DOCTYPE html>
2 <html>
3 <head>
4 <title> HomeTitle </title>
5 <style>
6
7 body{background: skyblue;}
8
9 </style>
10 <body>
11 <p> Welcome Home</p>
12 <div>
13
14 <form id ="redirect" method="POST">
15 <input type="submit"value="SignIn" >
16 <input type="submit" value="Exit" >
17 </form>
18 </body>
19 <script>
20 </script>
21
22 </head>
23 </html>// Importing the module
24const express=require("express")
25var bodyParser=require('body-parser')
26
27// Creating express Router
28const router=express.Router()
29var jsonParser= bodyParser.json()
30var urlencodedParser =bodyParser.urlencoded({extended: false});
31// Handling login request
32router.get("/",(req,res,next)=>{
33 res.render('home.ejs')
34})
35
36
37router.post("/", urlencodedParser, function (req,res){
38 return res.redirect("/login");
39})
40
41router.get("/login",(req,res,next)=>{
42 res.render("profile.ejs")
43})
44
45
46router.post("/login", urlencodedParser, function (req,res){
47
48 console.log(req.body)
49 //res.send(req.body.first)
50 return res.redirect('/');
51
52})
53module.exports=router<input type="submit" value="SignIn" name="submit">
54<input type="submit" value="Exit" name="submit">
55const submit = req.body.submit;
56if(submit === "SignIn"){
57 //Do something
58} else if(submit === "Exit"){
59 //Do Something
60} else {
61}
62
QUESTION
Few, complex OR many, simple MySQL queries?
Asked 2022-Mar-23 at 19:06Im working on a onlineshop with php.
I work with the mvc model and I divide each small part of my application in: model view controller and service ( service is there for the query ).
So for example I would have a Item cart which is divided in discription and price...
For each of them I would have a seperate query, for example the discription: 'SELECT discription OF ... WHERE ...'
So my questin is:
Is there any downside ( like a worse performance ) if I use many simple MySQL queries instead of one complex query?
ANSWER
Answered 2022-Mar-23 at 10:18Typically it is favorable to minimize the number of queries your application needs to execute. The reason for this is that each separate query requires a round trip to and from the database, which takes time and resources.
You did not include any actual queries, but most likely you would want to lean towards using the single complex query versus achieving the same with several queries.
QUESTION
Design pattern for Spring Boot back end and Angular front end
Asked 2022-Mar-11 at 05:09I have built an application that uses Spring Boot as back end and Angular as front end using APIs.
Spring Boot contains:
1Dao
2Controller
3Entity
4Service
5
and some classes.
After research I see that the design pattern for this structure is MVC (model view controller). But in this case view is in Angular.
What is the design pattern to use in this case, when we have back end and front end and relation between is using APIs?
ANSWER
Answered 2022-Mar-11 at 05:09Here, considering the broader picture, the entire architecture follows a Client-Server pattern.
Client: Angular App
Server: Backend Services
The Server can also be invoked directly, in which case those will be other clients alongside Angular App.
Internal to Backend service, other design patterns can be observed as DAO pattern, Factory pattern, Observer etc, but that would depend on whether you have actually used them.
QUESTION
I am having trouble using bind to change the this statement to point to my controller Javascript MVC
Asked 2021-Oct-05 at 17:01I am trying to implement model view controller pattern in a simple print hello world program. I can get everything to work properly except at the end after I click the button in my program. I am trying to bind my function to the controller so that way the function uses the this statements in the controller to access my model and view instances in the controller. When I click the button the this statements in my function are referencing my button object instead of the controller. I am having trouble using bind to change what the this statements point to. Please, any assistance would be greatly appreciated. thank you.
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <title> Hello World MVC </title>
5 <link rel="stylesheet" href="css file name">
6</head>
7<body>
8 <div id="container">
9 <input type=text id="textBox">
10 <button id="displayButton">Display</button>
11 </div>
12 <script src="mainbind.js"></script>
13</body>
14</html>
15
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <title> Hello World MVC </title>
5 <link rel="stylesheet" href="css file name">
6</head>
7<body>
8 <div id="container">
9 <input type=text id="textBox">
10 <button id="displayButton">Display</button>
11 </div>
12 <script src="mainbind.js"></script>
13</body>
14</html>
15function Model(text) {
16 this.data = text;
17};
18
19function View() {
20 this.displayButton = document.getElementById('displayButton');
21 this.textBox = document.getElementById('textBox');
22 this.initialize = function(displayButtonProcess) {
23 this.displayButton.addEventListener('click', displayButtonProcess);
24 }
25};
26
27function Controller(text) {
28
29 this.model = new Model(text);
30 this.view = new View;
31 this.buttonClick = function(event) {
32 // process the button click event
33 this.view.textBox.value = this.model.data;
34 };
35 this.view.initialize(this.buttonClick);
36};
37
38
39let x = new Controller("Hello World");
40x.buttonClick = x.buttonClick.bind(x);
41
ANSWER
Answered 2021-Oct-05 at 17:01The problem is that you are changing controller instance property after you have already used unbinded version as a callback.
You can fix it by binding directly when creating a controller. Or you should better use arrow functions instead.
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <title> Hello World MVC </title>
5 <link rel="stylesheet" href="css file name">
6</head>
7<body>
8 <div id="container">
9 <input type=text id="textBox">
10 <button id="displayButton">Display</button>
11 </div>
12 <script src="mainbind.js"></script>
13</body>
14</html>
15function Model(text) {
16 this.data = text;
17};
18
19function View() {
20 this.displayButton = document.getElementById('displayButton');
21 this.textBox = document.getElementById('textBox');
22 this.initialize = function(displayButtonProcess) {
23 this.displayButton.addEventListener('click', displayButtonProcess);
24 }
25};
26
27function Controller(text) {
28
29 this.model = new Model(text);
30 this.view = new View;
31 this.buttonClick = function(event) {
32 // process the button click event
33 this.view.textBox.value = this.model.data;
34 };
35 this.view.initialize(this.buttonClick);
36};
37
38
39let x = new Controller("Hello World");
40x.buttonClick = x.buttonClick.bind(x);
41this.buttonClick = () => this.view.textBox.value = this.model.value
42
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <title> Hello World MVC </title>
5 <link rel="stylesheet" href="css file name">
6</head>
7<body>
8 <div id="container">
9 <input type=text id="textBox">
10 <button id="displayButton">Display</button>
11 </div>
12 <script src="mainbind.js"></script>
13</body>
14</html>
15function Model(text) {
16 this.data = text;
17};
18
19function View() {
20 this.displayButton = document.getElementById('displayButton');
21 this.textBox = document.getElementById('textBox');
22 this.initialize = function(displayButtonProcess) {
23 this.displayButton.addEventListener('click', displayButtonProcess);
24 }
25};
26
27function Controller(text) {
28
29 this.model = new Model(text);
30 this.view = new View;
31 this.buttonClick = function(event) {
32 // process the button click event
33 this.view.textBox.value = this.model.data;
34 };
35 this.view.initialize(this.buttonClick);
36};
37
38
39let x = new Controller("Hello World");
40x.buttonClick = x.buttonClick.bind(x);
41this.buttonClick = () => this.view.textBox.value = this.model.value
42function Model(text) {
43 this.data = text;
44};
45
46function View() {
47 this.displayButton = document.getElementById('displayButton');
48 this.textBox = document.getElementById('textBox');
49 this.initialize = function(displayButtonProcess) {
50 this.displayButton.addEventListener('click', displayButtonProcess);
51 }
52};
53
54function Controller(text) {
55
56 this.model = new Model(text);
57 this.view = new View;
58 this.buttonClick = function(event) {
59 // process the button click event
60 this.view.textBox.value = this.model.data;
61 };
62 this.view.initialize(this.buttonClick.bind(this));
63};
64
65
66let x = new Controller("Hello World");
67// x.buttonClick = x.buttonClick.bind(x);
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <title> Hello World MVC </title>
5 <link rel="stylesheet" href="css file name">
6</head>
7<body>
8 <div id="container">
9 <input type=text id="textBox">
10 <button id="displayButton">Display</button>
11 </div>
12 <script src="mainbind.js"></script>
13</body>
14</html>
15function Model(text) {
16 this.data = text;
17};
18
19function View() {
20 this.displayButton = document.getElementById('displayButton');
21 this.textBox = document.getElementById('textBox');
22 this.initialize = function(displayButtonProcess) {
23 this.displayButton.addEventListener('click', displayButtonProcess);
24 }
25};
26
27function Controller(text) {
28
29 this.model = new Model(text);
30 this.view = new View;
31 this.buttonClick = function(event) {
32 // process the button click event
33 this.view.textBox.value = this.model.data;
34 };
35 this.view.initialize(this.buttonClick);
36};
37
38
39let x = new Controller("Hello World");
40x.buttonClick = x.buttonClick.bind(x);
41this.buttonClick = () => this.view.textBox.value = this.model.value
42function Model(text) {
43 this.data = text;
44};
45
46function View() {
47 this.displayButton = document.getElementById('displayButton');
48 this.textBox = document.getElementById('textBox');
49 this.initialize = function(displayButtonProcess) {
50 this.displayButton.addEventListener('click', displayButtonProcess);
51 }
52};
53
54function Controller(text) {
55
56 this.model = new Model(text);
57 this.view = new View;
58 this.buttonClick = function(event) {
59 // process the button click event
60 this.view.textBox.value = this.model.data;
61 };
62 this.view.initialize(this.buttonClick.bind(this));
63};
64
65
66let x = new Controller("Hello World");
67// x.buttonClick = x.buttonClick.bind(x);<div id="container">
68 <input type=text id="textBox">
69 <button id="displayButton">Display</button>
70</div>
QUESTION
Value from form input does not be transmit by the submit button. How can I fix that?
Asked 2021-May-06 at 10:08i try to add fields in a form by clicking a button. The fields appear and the validation works either. The problem is, that the value of these input fields isn't transmitted by the submit button of the form.
The framework is ASP.NET Core-Web-App (Model View Controller) with .Net 5.
I add the fields with the following code.
1 putMoreFields.addEventListener("click", function () {
2
3 myTextField.insertAdjacentHTML('afterend',
4 '<label asp-for="ContactMail" class="form-label"></label> <input type="email" class="form-control" asp-for="ContactMail" placeholder="name@example.com" required> <span asp-validation-for="ContactMail" class="text-danger"></span> </div> <div class="invalid-feedback"> Bitte geben Sie eine Mail-Adresse ein. </div> </div >')
5 myTextField.insertAdjacentHTML('afterend',
6 '<label asp-for="ContactMail" class="form-label"></label> <input type="date" class="form-control" asp-for="ContactMail" placeholder="dd.mm.jjjj" required> <span asp-validation-for="ContactMail" class="text-danger"></span> </div> <div class="invalid-feedback"> Bitte geben Sie eine Mail-Adresse ein. </div> </div >')
7
8})
9
Can someone help me?
Best regards
JuRi-2020
ANSWER
Answered 2021-May-06 at 10:08You just need change all the code
1 putMoreFields.addEventListener("click", function () {
2
3 myTextField.insertAdjacentHTML('afterend',
4 '<label asp-for="ContactMail" class="form-label"></label> <input type="email" class="form-control" asp-for="ContactMail" placeholder="name@example.com" required> <span asp-validation-for="ContactMail" class="text-danger"></span> </div> <div class="invalid-feedback"> Bitte geben Sie eine Mail-Adresse ein. </div> </div >')
5 myTextField.insertAdjacentHTML('afterend',
6 '<label asp-for="ContactMail" class="form-label"></label> <input type="date" class="form-control" asp-for="ContactMail" placeholder="dd.mm.jjjj" required> <span asp-validation-for="ContactMail" class="text-danger"></span> </div> <div class="invalid-feedback"> Bitte geben Sie eine Mail-Adresse ein. </div> </div >')
7
8})
9asp-for="ContactMail"
10
to
1 putMoreFields.addEventListener("click", function () {
2
3 myTextField.insertAdjacentHTML('afterend',
4 '<label asp-for="ContactMail" class="form-label"></label> <input type="email" class="form-control" asp-for="ContactMail" placeholder="name@example.com" required> <span asp-validation-for="ContactMail" class="text-danger"></span> </div> <div class="invalid-feedback"> Bitte geben Sie eine Mail-Adresse ein. </div> </div >')
5 myTextField.insertAdjacentHTML('afterend',
6 '<label asp-for="ContactMail" class="form-label"></label> <input type="date" class="form-control" asp-for="ContactMail" placeholder="dd.mm.jjjj" required> <span asp-validation-for="ContactMail" class="text-danger"></span> </div> <div class="invalid-feedback"> Bitte geben Sie eine Mail-Adresse ein. </div> </div >')
7
8})
9asp-for="ContactMail"
10 name="ContacMail"
11
QUESTION
How can i deploy my website on Heroku properly?
Asked 2021-May-06 at 03:41I've trying to deploy my website on Heroku, the implementation that i used for this it's Model View Controller with PHP. I don't know what happend but when i try to access to the main page (or index) this works perfectly, when i'm trying to access other pages on mi website something occurs like this:
I know one reason which this is happening, i used in my Router the next:
1$currentURL = $_SERVER['PATH_INFO'] ?? '/';
2 //var_dump($_SERVER);
3
4 $method = $_SERVER['REQUEST_METHOD'];
5
6 if($method === 'GET'){
7 $fn = $this->routesGET[$currentURL] ?? null;
8 } else{
9 $fn = $this->routesPOST[$currentURL] ?? null;
10 }
11
So, i displayed global variable of PHP $_SERVER on my website and i noticed $_SERVER['PATH_INFO']
doesn't appear on it. So, i guess that the problem comes from Apache's configuration because i use Apache2 and PHP for this. So, i don't know how configure because it's my first time doing this, if you can help me, i'll really thank to you.
Here is my directory: enter image description here
And, finally my procfile:
1$currentURL = $_SERVER['PATH_INFO'] ?? '/';
2 //var_dump($_SERVER);
3
4 $method = $_SERVER['REQUEST_METHOD'];
5
6 if($method === 'GET'){
7 $fn = $this->routesGET[$currentURL] ?? null;
8 } else{
9 $fn = $this->routesPOST[$currentURL] ?? null;
10 }
11web: vendor/bin/heroku-php-apache2 public/
12
ANSWER
Answered 2021-May-06 at 03:41These are the general appliable steps of configuring an MVC-based web application. Presumed web server version for the settings below: Apache HTTP Server v2.4.
1) Block access to all directories and files:
First of all, in the config file of Apache, the access to all directories and files should be blocked by default:
1$currentURL = $_SERVER['PATH_INFO'] ?? '/';
2 //var_dump($_SERVER);
3
4 $method = $_SERVER['REQUEST_METHOD'];
5
6 if($method === 'GET'){
7 $fn = $this->routesGET[$currentURL] ?? null;
8 } else{
9 $fn = $this->routesPOST[$currentURL] ?? null;
10 }
11web: vendor/bin/heroku-php-apache2 public/
12# Do not allow access to the root filesystem.
13<Directory />
14 Options FollowSymLinks
15 AllowOverride None
16 Require all denied
17</Directory>
18
19# Prevent .htaccess and .htpasswd files from being viewed by Web clients.
20<FilesMatch "^\.ht">
21 Require all denied
22</FilesMatch>
23
2) Allow access to a default directory:
The access to a default directory (here /var/www/
), supposedly used for projects, should then be allowed:
1$currentURL = $_SERVER['PATH_INFO'] ?? '/';
2 //var_dump($_SERVER);
3
4 $method = $_SERVER['REQUEST_METHOD'];
5
6 if($method === 'GET'){
7 $fn = $this->routesGET[$currentURL] ?? null;
8 } else{
9 $fn = $this->routesPOST[$currentURL] ?? null;
10 }
11web: vendor/bin/heroku-php-apache2 public/
12# Do not allow access to the root filesystem.
13<Directory />
14 Options FollowSymLinks
15 AllowOverride None
16 Require all denied
17</Directory>
18
19# Prevent .htaccess and .htpasswd files from being viewed by Web clients.
20<FilesMatch "^\.ht">
21 Require all denied
22</FilesMatch>
23<Directory /var/www/>
24 Options Indexes FollowSymLinks
25 AllowOverride None
26 Require all granted
27</Directory>
28
My recommendation: For security reasons, this location should contain only a index.php
and a index.html
file, each of them displaying a simple "Hello" message. All web projects should be created in other directories and the access to them should be set separately, as described below.
3) Set access to a separate project directory:
Let's suppose that you create your project in another location (like in the directory /path/to/my/sample/mvc/
) than the default one (/var/www/
). Then, taking into consideration, that only the subfolder public
should be accessible from outside, create a web server configuration for it, like this:
1$currentURL = $_SERVER['PATH_INFO'] ?? '/';
2 //var_dump($_SERVER);
3
4 $method = $_SERVER['REQUEST_METHOD'];
5
6 if($method === 'GET'){
7 $fn = $this->routesGET[$currentURL] ?? null;
8 } else{
9 $fn = $this->routesPOST[$currentURL] ?? null;
10 }
11web: vendor/bin/heroku-php-apache2 public/
12# Do not allow access to the root filesystem.
13<Directory />
14 Options FollowSymLinks
15 AllowOverride None
16 Require all denied
17</Directory>
18
19# Prevent .htaccess and .htpasswd files from being viewed by Web clients.
20<FilesMatch "^\.ht">
21 Require all denied
22</FilesMatch>
23<Directory /var/www/>
24 Options Indexes FollowSymLinks
25 AllowOverride None
26 Require all granted
27</Directory>
28ServerName www.my-sample-mvc.com
29DocumentRoot "/path/to/my/sample/mvc/public"
30
31<Directory "/path/to/my/sample/mvc/public">
32 Require all granted
33
34 # When Options is set to "off", then the RewriteRule directive is forbidden!
35 Options FollowSymLinks
36
37 # Activate rewriting engine.
38 RewriteEngine On
39
40 # Allow pin-pointing to index.php using RewriteRule.
41 RewriteBase /
42
43 # Rewrite url only if no physical folder name is given in url.
44 RewriteCond %{REQUEST_FILENAME} !-d
45
46 # Rewrite url only if no physical file name is given in url.
47 RewriteCond %{REQUEST_FILENAME} !-f
48
49 # Parse the request through index.php.
50 RewriteRule ^(.*)$ index.php [QSA,L]
51</Directory>
52
Note that the above settings can be defined either:
- in the config file of Apache, or
- in a .htaccess file inside the project, or
- in a virtual host definition file.
In case a virtual host definition file is used, the settings must be included between the tags <VirtualHost>
and </VirtualHost>
:
1$currentURL = $_SERVER['PATH_INFO'] ?? '/';
2 //var_dump($_SERVER);
3
4 $method = $_SERVER['REQUEST_METHOD'];
5
6 if($method === 'GET'){
7 $fn = $this->routesGET[$currentURL] ?? null;
8 } else{
9 $fn = $this->routesPOST[$currentURL] ?? null;
10 }
11web: vendor/bin/heroku-php-apache2 public/
12# Do not allow access to the root filesystem.
13<Directory />
14 Options FollowSymLinks
15 AllowOverride None
16 Require all denied
17</Directory>
18
19# Prevent .htaccess and .htpasswd files from being viewed by Web clients.
20<FilesMatch "^\.ht">
21 Require all denied
22</FilesMatch>
23<Directory /var/www/>
24 Options Indexes FollowSymLinks
25 AllowOverride None
26 Require all granted
27</Directory>
28ServerName www.my-sample-mvc.com
29DocumentRoot "/path/to/my/sample/mvc/public"
30
31<Directory "/path/to/my/sample/mvc/public">
32 Require all granted
33
34 # When Options is set to "off", then the RewriteRule directive is forbidden!
35 Options FollowSymLinks
36
37 # Activate rewriting engine.
38 RewriteEngine On
39
40 # Allow pin-pointing to index.php using RewriteRule.
41 RewriteBase /
42
43 # Rewrite url only if no physical folder name is given in url.
44 RewriteCond %{REQUEST_FILENAME} !-d
45
46 # Rewrite url only if no physical file name is given in url.
47 RewriteCond %{REQUEST_FILENAME} !-f
48
49 # Parse the request through index.php.
50 RewriteRule ^(.*)$ index.php [QSA,L]
51</Directory>
52<VirtualHost *:80>
53 ... here come the settings ...
54</VirtualHost>
55
Note: Don't forget to restart the web server after each change of the configuration settings.
Some resources:
QUESTION
Send Post request in Node js Rest API
Asked 2021-Feb-04 at 16:07I CAN'T SEND POST REQUEST FROM CLIENT SIDE !
I need to send HTTP Post request in Node js Rest API to the payment gateway. Post request needs to have headers and body payload. I have frontend and backend separated, I'm using Rest API with express.js and payment gateway needs server to server communication so I can't to do that from client side. Basically when user clicks on payment I need to send call to my backend server then my backend server needs to send request to the payment gateway.
Payment gateway has documentation with only MVC ( Model View Controller ) and they really can't help.
So logic inside controller should be something like this
1exports.payment = (req, res, next) => {
2 const { amount, id, currency } = req.body;
3
4 //add headers
5 //create body paloyad
6
7 //send request to https://payment....com/api-key/transaction
8
9 //receive response
10
11 res.status(200).json({ status: 'success' });
12}
13
14
ANSWER
Answered 2021-Feb-04 at 15:27Use Axios to send POST requests. Its much easier.
1exports.payment = (req, res, next) => {
2 const { amount, id, currency } = req.body;
3
4 //add headers
5 //create body paloyad
6
7 //send request to https://payment....com/api-key/transaction
8
9 //receive response
10
11 res.status(200).json({ status: 'success' });
12}
13
14const axios = require('axios')
15
16
17let config = {
18 headers: {
19 header1: value,
20 }
21}
22
23let data = {
24 'amount': amount,
25 'id':id,
26 'currency':currency,
27}
28
29
30axios.post('https://payment....com/api-key/transaction', data,config)
31 .then(function (response) {
32 console.log(response);
33 })
34
QUESTION
Suggestions on REST API & Software Architecture Style
Asked 2020-Nov-16 at 15:47First of all i am student, so i need to know how compounds Interact with each other, Maybe next time in the future i will do it with a framework, but first thing I need to do is knowing how to build the software form scratch.
My project will be web and mobile application so I decided to create a rest api for both... I will implement my project in Native PHP.
- What is the best practice for software architecture style?
but I don’t know what is the best practice software architecture for my rest api Multitiered(mvc, mvp, Or even something else like (model view controller data access))
my idea about Multitiered(model view controller data access)
1class Controller
2{
3 public $view;
4 public $model;
5 public $dataAccess;
6
7 public function __construct()
8 {
9 $this->view = new View();
10 $this->model = new Model();
11 $this->dataAccess = new DataAccess();
12 }
13}
14class UserController extends Controller
15{
16 public function __construct()
17 {
18 $this->model->tableName = "users";
19 }
20
21 public function get($id)
22 {
23 if($id)
24 {
25 $this->model->data = $this->dataAccess->selectById($this->model->tableName, $id);
26 $this->view->render($this->model->data);
27 }
28 else
29 {
30 $this->view->renderError();
31 }
32
33 }
34}
35class Application
36{
37 private function __construct()
38 {}
39
40 public static function run()
41 {
42 $router = new Router();
43 $router->get("/users/([0-9]+)", array("UserController", "get"));
44 $router->run();
45 }
46}
47
What about the file structure ?
app/
The app directory contains our rest-api components like controllers, views, models, data access.
core/
The directory contains the Router class and the basic classes
Bootstrap/
The directory contains the application.php file which bootstraps the framework by run function and autoload.php file which automatically loading PHP files.
storage/
logs, file caches, and user-generated files.
What about authentication and authorization?
Will I need an extra layer for my architecture, model-view-controller-data access-(middleware or router)
How will the rest api interact with other layers? For example, does the (middleware or router) layer interact with the controller then controller interact with data access layer for every authentication and authorization process
I will attach a simple implementation of the current phase to review my thoughts.
https://github.com/mahmoudahmedd/i-am-asking-for-feedback
Any other comments I would be grateful, Finally thanks.
ANSWER
Answered 2020-Nov-16 at 15:47great solution: learn on base applications of top frameworks.
- Class Model work with DataAccess inside model
- Models must extends Model
- Controllers contain 'action...' methods to wrap model methods: 'actionGet', 'actionCreate', 'actionDelete' and etc. Route:
namespace/controller/action
, for example:api/user/get
callController\Api\User::actionGet()
.
For example: https://github.com/koseven/koseven/blob/devel/system/classes/KO7/Controller.php , https://github.com/koseven/koseven/blob/devel/system/classes/KO7/Controller/Template.php
QUESTION
Preserve Button State When Switching Between View Controllers
Asked 2020-Jul-05 at 09:57I currently have a navigation controller with 2 view controllers. After clicking Button A on VC 1, it brings me to VC 2. VC 2 has a checklist. When selecting the desired items from the checklist, I am able to select and deselect the checklist buttons. Then I click the back button on VC2 to return to VC 1. When I want to edit the checklist in VC 2, I click Button A to go back to VC 2 but the checklist has reset back to its default state and none of my selections are saved.
I have looked into Model View Controllers, Unwind Segues, UserData, Popping View Controllers but I am still very confused as to what to pick and stick to, for this to work.
Any help is much appreciated. Thanks.
ANSWER
Answered 2020-Jul-05 at 09:57QUESTION
Areas, pages, and layouts in .NET Core 3.1
Asked 2020-Jun-15 at 07:50I have created a blank template MVC project with user accounts in Visual Studio 2019, i.e. ASP.NET Core Web Application -> Web Application (Model View Controller), Authentication = Individual user accounts.
When you run the project, you can navigate to the pages for /Identity/Account/Register and /Identity/Account/Login. However, I can't see any reference to these pages in the project structure.
The Areas/Identity folder does not contain any controllers or views, and I can't see any custom routing which redirect Identity/Account/Register to a different controller action.
Where is the html for these pages generated?
ANSWER
Answered 2020-Jun-14 at 18:14If you create the application by selecting "MVC" option, the account controller is scaffolded for you. But if you select "Web Application", Razor page application will be created and all the views related to identity section will be loaded from a Razor Class Library (Microsoft.AspNetCore.Identity.UI).
You can still customize and use you custom view pages for Identity section.
Community Discussions contain sources that include Stack Exchange Network
Tutorials and Learning Resources in Model View Controller
Tutorials and Learning Resources are not available at this moment for Model View Controller