search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

Home Backend Development XML/RSS Tutorial PlayFramework completely implements an APP (9)

PlayFramework completely implements an APP (9)

Dec 23, 2016 pm 04:46 PM
app

Add add, delete, modify and check operations

1. Enable CRUD Module

Add in /conf/application.conf

# Import the crud module
module.crud=${play.path}/modules/crud

 

Add

# Import CRUD routes
* in /conf/routes /admin

/app/controllers

import play.*;import play.mvc.*;

public class Posts extends CRUD {

}public class Tags extends CRUD {

}public class Users extends CRUD {

}public class Comments extends CRUD {

}


may prompt an error: CRUD cannot be parsed to type and running the program will prompt an error

Solution:

Modify conf/dependencies.yml

require:

- play

- play -> crud

 

Run Shell

> play dependencies


 

The modules/crud file will be generated under the project. Just restart the project, but compilation will still cause errors. It may be because the crud project is not referenced


3. Create Controller

package controllers;import models.User;

@CRUD.For(User.class)public class AdminUsers extends CRUD {

}PlayFramework completely implements an APP (9)

4. Modify the Model and add verification

Take User as an example

public class User extends Model {
@Email

@Required public String email;

@Required

@PassWord

public String password; public String fullname; public String isAdmin; public String toString() { return email;

}

}





Enter http://localhost:9000/admin/ Select add user to enter User Form for testing



public class Post extends Model {
@Required public String title;

@Required public Date postedAt;

@Lob

@Required

@MaxSize(10000) public String content;

@Required
@ManyToOne public User author;

@OneToMany(mappedBy = "post", cascade = CascadeType.ALL) Public List comments ;

@ManyToMany(cascade = CascadeType.PERSIST) public Set tags;
}




public class Tag extends Model implements Comparable {

@Required public String name;
}

public class Comment extends Model {

@Required public String author;
@Required public Date postedAt;

@Lob
@Required

@MaxSize(10000) public String content;

@ManyToOne

@Required public Post post ;
}




5. The Label name displayed on the page is lowercase, consistent with the field name of the corresponding class. If you want to display uppercase, you can modify /conf/messages

title=Title
content=Content
postedAt= Posted at
author=Author
post=Related post

tags=Tags set

name=Common name

email=Email

password=Password

fullname=Full name

isAdmin=User is admin





The above is the complete PlayFramework Implement the content of an APP (9). For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!




Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

ArtGPT

ArtGPT

AI image generator for creative art from text prompts.

Stock Market GPT

Stock Market GPT

AI powered investment research for smarter decisions

Popular tool

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to identify the 'hype' and 'real value' of an NFT project? How to identify the 'hype' and 'real value' of an NFT project? Feb 12, 2026 am 10:12 AM

The credibility of the project needs to be comprehensively assessed from five aspects: team background, on-chain data, community quality, contract audit, and cross-platform consistency: verify the team's openness and technical resume, analyze on-chain activity and position distribution, verify the authenticity of community content and technical response, confirm the effectiveness of third-party audits and contract security, and compare data deviations across multiple platforms to identify manipulation risks.

Decentraland (MANA): a virtual world platform in the metaverse Decentraland (MANA): a virtual world platform in the metaverse Feb 27, 2026 pm 10:18 PM

Decentraland is a decentralized virtual reality platform based on Ethereum. Its LAND is ERC-721NFT. It is driven by MANA tokens for transactions and DAO governance. It supports users to create and deploy 3D scenes and bind ENS identities.

Why is it said that 'free lunch' is often the most expensive in the currency circle? Why is it said that 'free lunch' is often the most expensive in the currency circle? Feb 10, 2026 pm 10:36 PM

The “free lunch” is actually a high-risk trap: airdrops store liquidity and honeypot risks; zero handling fees hide the price difference; rebates are tied to long-term lock-ups; NFT whitelists trigger Gas auctions; signature authorization may cause assets to get out of control.

How do I join a project's 'Early Contributor' program? How do I join a project's 'Early Contributor' program? Feb 12, 2026 pm 09:43 PM

The early contributor program needs to complete five steps: 1. Follow official social media and join the community; 2. Verify tasks on the chain; 3. Submit original technical articles; 4. Discord role certification; 5. Participate in governance voting.

Cardano (ADA): Representative of the academic public chain Cardano (ADA): Representative of the academic public chain Feb 27, 2026 pm 09:51 PM

Cardano protocol upgrades are subject to academic peer review, a layered architecture decouples the settlement and computing layers, Plutus implements deterministic execution based on Haskell, governance voting is weighted by ADA balance, and native tokens are issued with zero gas.

Detailed explanation of the 'lending' protocol: how to mortgage assets on the chain to lend stablecoins Detailed explanation of the 'lending' protocol: how to mortgage assets on the chain to lend stablecoins Feb 12, 2026 pm 09:46 PM

Users need to choose an audited mainstream chain lending protocol (such as Aave), connect Qianbao to authorize mortgage assets, deposit ETH and other collateral to generate positions, lend stablecoins such as USDC/DAI, and monitor health factors in real time to prevent liquidation risks.

Aave (AAVE): A giant in the decentralized lending market Aave (AAVE): A giant in the decentralized lending market Feb 25, 2026 pm 10:00 PM

AAVE is the leading decentralized lending protocol in the DeFi field, supporting multi-asset liquidity pools, flash loans, interest rate model switching, cross-market position migration and GHO stablecoin minting.

Analysis of reordering rules in Java_Happens-Before principle and the use of memory barriers Analysis of reordering rules in Java_Happens-Before principle and the use of memory barriers Feb 13, 2026 pm 07:24 PM

Java reordering occurs when the compiler, JIT or CPU adjusts the order of instructions to optimize performance without destroying the happens-before relationship. It is common in scenarios such as multi-threaded shared variable reading and writing, and objects that are not safely released.

Related articles