Review textArea and length fixed and improved

This commit is contained in:
Martinagr32 2021-04-03 00:27:18 +02:00
parent dcfb78ec2a
commit 1bc2941f60
4 changed files with 72 additions and 37 deletions

View file

@ -1,5 +1,6 @@
package org.springframework.cheapy.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@ -17,6 +18,7 @@ public class Review extends BaseEntity{
private static final long serialVersionUID = 1L;
@NotBlank(message = "Debe rellenar la valoración de Cheapy")
@Column(length=16777215)
private String opinion;
@NotNull

View file

@ -13,7 +13,7 @@
<form:form modelAttribute="review" class="form-horizontal" id="add-review-form">
<div class="form-group has-feedback">
<form:hidden path="id"/>
<cheapy:inputField label="Opinión" name="opinion"/>
<cheapy:textAreaField label="Opinión" name="opinion"/>
<cheapy:inputField label="Estrellas" name="stars"/>
</div>
<div class="form-group">

View file

@ -11,44 +11,49 @@
<table id="reviewTable" class="table table-striped">
<thead>
<tr>
<!-- <th style="width: 150px;">Restaurante</th> -->
<th><fmt:message key="user"/></th>
<th><fmt:message key="stars"/></th>
<th><fmt:message key="opinion"/></th>
<th> </th>
</tr>
<tr>
<!-- <th style="width: 150px;">Restaurante</th> -->
<th><fmt:message key="user"/></th>
<th><fmt:message key="stars"/></th>
<th><fmt:message key="opinion"/></th>
<th> </th>
</tr>
</thead>
<tbody>
<c:forEach items="${reviewsLs}" var="review">
<tr>
<!-- <td> -->
<%-- <c:out value="nombre por definir"/> <!-- ${review.usuario.nombre},${review.usuario.apellidos} --> --%>
<!-- </td> -->
<td>
<c:out value="${review.escritor.username}"/>
</td>
<td>
<c:out value="${review.stars}"/>
</td>
<td>
<c:out value="${review.opinion}"/>
</td>
<td>
<spring:url value="/reviews/{reviewId}" var="reviewUrl">
<spring:param name="reviewId" value="${review.id}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(reviewUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/></button>
</div>
</td>
</tr>
</c:forEach>
<c:choose>
<c:when test="${fn:length(reviewsLs) == 0}">
<tr><td colspan="4"><em><c:out value="No se ha realizado ninguna valoración por el momento."/></em></td></tr>
</c:when>
<c:otherwise>
<c:forEach items="${reviewsLs}" var="review">
<tr>
<!-- <td> -->
<%-- <c:out value="nombre por definir"/> <!-- ${review.usuario.nombre},${review.usuario.apellidos} --> --%>
<!-- </td> -->
<td>
<c:out value="${review.escritor.username}"/>
</td>
<td>
<c:out value="${review.stars}"/>
</td>
<td>
<c:out value="${review.opinion}"/>
</td>
<td>
<spring:url value="/reviews/{reviewId}" var="reviewUrl">
<spring:param name="reviewId" value="${review.id}"/>
</spring:url>
<div class="btn-detalles">
<button type="button" role="link" onclick="window.location='${fn:escapeXml(reviewUrl)}'" style="font-family: 'Lobster'; font-size: 20px;">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true" style="padding: 5px"> </span>
<fmt:message key="details"/></button>
</div>
</td>
</tr>
</c:forEach>
</c:otherwise>
</c:choose>
</tbody>
</table>
</cheapy:layout>

View file

@ -0,0 +1,28 @@
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ attribute name="name" required="true" rtexprvalue="true"
description="Name of corresponding property in bean object" %>
<%@ attribute name="label" required="true" rtexprvalue="true"
description="Label appears in red color if input is considered as invalid after submission" %>
<%@ attribute name="placeholder" required="false" rtexprvalue="true"
description="Example for input field" %>
<spring:bind path="${name}">
<c:set var="cssGroup" value="form-group ${status.error ? 'has-error' : '' }"/>
<c:set var="valid" value="${not status.error and not empty status.actualValue}"/>
<div class="${cssGroup}">
<label class="col-sm-2 control-label">${label}</label>
<div class="col-sm-10">
<form:textarea class="form-control" rows = "5" cols = "30" path="${name}"/>
<c:if test="${valid}">
<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
</c:if>
<c:if test="${status.error}">
<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>
<span class="help-inline">${status.errorMessage}</span>
</c:if>
</div>
</div>
</spring:bind>