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)

Bitcoin bullish signal lights up, BTC price may usher in a reversal Bitcoin bullish signal lights up, BTC price may usher in a reversal Jan 27, 2026 pm 08:51 PM

Recent market data shows that Bitcoin (BTC) has seen a number of bullish signals, including increased on-chain capital inflows and amplified trading volume, which may lead to a price reversal in the short term. Investors need to pay attention to market dynamics and seize potential trading opportunities.

What is a mnemonic phrase? What is the difference between mnemonic phrase and private key? What is a mnemonic phrase? What is the difference between mnemonic phrase and private key? Jan 27, 2026 pm 08:57 PM

In the field of cryptocurrency, mnemonics and private keys are the core tools for managing digital assets, but they are different in their role and use. Understanding their differences can help users manage their assets safely and prevent the loss of funds.

What is a cryptocurrency exchange? Differences between CEX and DEX, operation methods and tax analysis What is a cryptocurrency exchange? Differences between CEX and DEX, operation methods and tax analysis Jan 27, 2026 pm 09:00 PM

Cryptocurrency exchange refers to the behavior of users buying, selling or exchanging different digital assets on the platform. According to different operating models, they are mainly divided into centralized exchanges (CEX) and decentralized exchanges (DEX). This article will analyze the differences, operation methods and related tax issues between the two to help investors better understand the crypto asset trading environment.

Beginner's Guide to Dogecoin, Ethereum and Bitcoin: Core Analysis, Coin Selection and Risk Tips Beginner's Guide to Dogecoin, Ethereum and Bitcoin: Core Analysis, Coin Selection and Risk Tips Jan 27, 2026 pm 08:48 PM

For newcomers to the crypto market, it is very important to choose the right digital assets and master the basic operations. This article will take Dogecoin (DOGE), Ethereum (ETH) and Bitcoin (BTC) as examples to analyze the core concepts, trading channels and investment risk tips to help users get started smoothly.

Understand RWA in one article: The meaning of digital assets and a guide to leading tokens on the track Understand RWA in one article: The meaning of digital assets and a guide to leading tokens on the track Jan 27, 2026 pm 09:03 PM

With the development of the digital asset field, RWA (Real World Assets, digitization of real assets) has gradually become a hot topic in the market. RWA maps real-world assets, such as bonds, real estate or commodities, to the blockchain to achieve digital transactions and improve liquidity. This article will analyze the basic concepts, market applications and leading tokens of RWA to help investors quickly understand and participate.

What is the funding rate? Analysis of the operating principles and practical skills of perpetual contracts What is the funding rate? Analysis of the operating principles and practical skills of perpetual contracts Jan 27, 2026 pm 09:06 PM

The funding rate is one of the core mechanisms in the perpetual contract market. It is used to maintain a close connection between the contract price and the underlying spot price. Understanding funding rates and their operating principles is crucial for perpetual contract traders to grasp market dynamics and optimize trading strategies. This article will provide you with a detailed analysis of the operating logic and practical skills of funding rates.

What is ForU AI reputation airdrop? How to join and how to claim rewards What is ForU AI reputation airdrop? How to join and how to claim rewards Jan 27, 2026 pm 09:09 PM

Recently, ForU AI officially launched a reputation airdrop event to reward early users and active community members. By participating in the airdrop, users can obtain a certain number of token rewards and at the same time improve their credibility on the platform. This article will introduce in detail how to participate in the ForU AI reputation airdrop and the reward application process to help users obtain rewards smoothly.

What is Ethereum (ETH)? Interpretation of market prospects and complete purchasing tutorial What is Ethereum (ETH)? Interpretation of market prospects and complete purchasing tutorial Jan 30, 2026 pm 02:54 PM

Ethereum (ETH) is one of the most important assets in the current encryption market after Bitcoin. It is both a digital asset and an infrastructure that supports the operation of a large number of decentralized applications. This article will focus on the core concepts, market prospects and actual purchase process of Ethereum to help users systematically understand and participate in ETH transactions.

Related articles