added feedbackpanel cant post message with zero length text
Change-Id: Ide88e6abd9304cafdfa6baece4df114c86365c80
This commit is contained in:
parent
3c479a9998
commit
a31147d46c
src/main/java/se/su/dsv/scipro/conference/panels
@ -6,27 +6,27 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<wicket:panel>
|
<wicket:panel>
|
||||||
|
|
||||||
<div class="margin rounded-border">
|
<div class="margin rounded-border">
|
||||||
|
<div wicket:id="feedbackPanel"></div>
|
||||||
<form wicket:id="sendForm">
|
<form wicket:id="sendForm">
|
||||||
<textarea wicket:id="textArea"></textarea>
|
<textarea wicket:id="textArea"></textarea>
|
||||||
<div>
|
<div>
|
||||||
<button type="submit" wicket:id="ajaxButton">
|
<button type="submit" wicket:id="ajaxButton">
|
||||||
<img src="css/blueprint/plugins/buttons/icons/tick.png" alt="" />Send
|
<img src="css/blueprint/plugins/buttons/icons/tick.png" alt="" />Send
|
||||||
Message
|
Message
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div wicket:id="container" class="margin clear">
|
<div wicket:id="container" class="margin clear">
|
||||||
<div wicket:id="boardMessageDataView" class="rounded-border">
|
<div wicket:id="boardMessageDataView" class="rounded-border">
|
||||||
<span wicket:id="messageUser" class="small"> </span>
|
<span wicket:id="messageUser" class="small"> </span> <span
|
||||||
<span wicket:id="messageDate" class="small"></span>
|
wicket:id="messageDate" class="small"></span> <span><a
|
||||||
<span><a href="#"
|
href="#" wicket:id="delete" class="right-corner-resource"> <img
|
||||||
wicket:id="delete" class="right-corner-resource"> <img class="icon-12"
|
class="icon-12" src="images/icons/delete_16x16.png" alt="Delete"
|
||||||
src="images/icons/delete_16x16.png" alt="Delete" title="Delete" />
|
title="Delete" /> </a> </span>
|
||||||
</a>
|
|
||||||
</span>
|
|
||||||
<div wicket:id="messageLabel" class="margin"></div>
|
<div wicket:id="messageLabel" class="margin"></div>
|
||||||
<div>
|
<div>
|
||||||
<a href="#" wicket:id="showComments"><span
|
<a href="#" wicket:id="showComments"><span
|
||||||
|
@ -15,6 +15,7 @@ import org.apache.wicket.markup.html.basic.Label;
|
|||||||
import org.apache.wicket.markup.html.form.Form;
|
import org.apache.wicket.markup.html.form.Form;
|
||||||
import org.apache.wicket.markup.html.form.TextArea;
|
import org.apache.wicket.markup.html.form.TextArea;
|
||||||
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
|
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
|
||||||
|
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||||
import org.apache.wicket.markup.html.panel.Panel;
|
import org.apache.wicket.markup.html.panel.Panel;
|
||||||
import org.apache.wicket.markup.repeater.Item;
|
import org.apache.wicket.markup.repeater.Item;
|
||||||
import org.apache.wicket.markup.repeater.data.DataView;
|
import org.apache.wicket.markup.repeater.data.DataView;
|
||||||
@ -59,6 +60,7 @@ public class ConferencePanel extends Panel {
|
|||||||
private IModel<MessageBoard> messageBoardModel;
|
private IModel<MessageBoard> messageBoardModel;
|
||||||
private IModel<BoardMessage> boardMessageModel;
|
private IModel<BoardMessage> boardMessageModel;
|
||||||
private Set<SubscriberModel> subscriberModels;
|
private Set<SubscriberModel> subscriberModels;
|
||||||
|
private FeedbackPanel feedbackPanel;
|
||||||
|
|
||||||
public ConferencePanel(String id, IModel<MessageBoard> messageBoardModel,
|
public ConferencePanel(String id, IModel<MessageBoard> messageBoardModel,
|
||||||
Set<SubscriberModel> subscriberModels, IModel<BoardMessage> boardMessageModel) {
|
Set<SubscriberModel> subscriberModels, IModel<BoardMessage> boardMessageModel) {
|
||||||
@ -75,6 +77,10 @@ public class ConferencePanel extends Panel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initPanel() {
|
private void initPanel() {
|
||||||
|
feedbackPanel = new FeedbackPanel("feedbackPanel");
|
||||||
|
feedbackPanel.setOutputMarkupId(true);
|
||||||
|
add(feedbackPanel);
|
||||||
|
|
||||||
add(new SendWallMessageForm("sendForm"));
|
add(new SendWallMessageForm("sendForm"));
|
||||||
webMarkupContainer = new WebMarkupContainer("container");
|
webMarkupContainer = new WebMarkupContainer("container");
|
||||||
loadUserDataView(new BoardMessageDataProvider(messageBoardModel));
|
loadUserDataView(new BoardMessageDataProvider(messageBoardModel));
|
||||||
@ -140,7 +146,7 @@ public class ConferencePanel extends Panel {
|
|||||||
subscriberModels, messageBoardModel.getObject().getTitle());
|
subscriberModels, messageBoardModel.getObject().getTitle());
|
||||||
ctp.setOutputMarkupPlaceholderTag(true);
|
ctp.setOutputMarkupPlaceholderTag(true);
|
||||||
webMarkupContainer.add(ctp);
|
webMarkupContainer.add(ctp);
|
||||||
|
|
||||||
if (boardMessageModel != null && boardMessageModel.getObject().equals(bm)) {
|
if (boardMessageModel != null && boardMessageModel.getObject().equals(bm)) {
|
||||||
comment.setDefaultModelObject("Hide comments");
|
comment.setDefaultModelObject("Hide comments");
|
||||||
webMarkupContainer.setVisible(true);
|
webMarkupContainer.setVisible(true);
|
||||||
@ -231,25 +237,30 @@ public class ConferencePanel extends Panel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
|
||||||
|
if (message == null || message.length() < 1) {
|
||||||
|
error("Post can't be empty");
|
||||||
|
} else {
|
||||||
|
BoardMessage bm = new BoardMessage();
|
||||||
|
bm.setMessage(message);
|
||||||
|
bm.setMessageBoard(messageBoardModel.getObject());
|
||||||
|
bm.setFromUser(SciProSession.get().getUser());
|
||||||
|
bm = boardMessageDao.save(bm);
|
||||||
|
|
||||||
BoardMessage bm = new BoardMessage();
|
for (SubscriberModel subscriberModel : subscriberModels) {
|
||||||
bm.setMessage(message);
|
notificationController.createNotificationForConference(subscriberModel.getUser(), message, messageBoardModel.getObject().getTitle(),
|
||||||
bm.setMessageBoard(messageBoardModel.getObject());
|
subscriberModel.getNotificationPriority(),
|
||||||
bm.setFromUser(SciProSession.get().getUser());
|
subscriberModel.getAbsolutePath());
|
||||||
bm = boardMessageDao.save(bm);
|
}
|
||||||
|
messageTextArea.setDefaultModelObject("");
|
||||||
for (SubscriberModel subscriberModel : subscriberModels) {
|
webMarkupContainer.removeAll();
|
||||||
createNotification(subscriberModel.getUser(), message,
|
loadUserDataView(new BoardMessageDataProvider(messageBoardModel));
|
||||||
subscriberModel.getNotificationPriority(),
|
webMarkupContainer.add(dataView);
|
||||||
subscriberModel.getAbsolutePath());
|
webMarkupContainer.add(new PagingNavigator("pagingNavigator", dataView));
|
||||||
|
target.addComponent(webMarkupContainer);
|
||||||
|
target.addComponent(messageTextArea);
|
||||||
|
|
||||||
}
|
}
|
||||||
messageTextArea.setDefaultModelObject("");
|
target.addComponent(feedbackPanel);
|
||||||
webMarkupContainer.removeAll();
|
|
||||||
loadUserDataView(new BoardMessageDataProvider(messageBoardModel));
|
|
||||||
webMarkupContainer.add(dataView);
|
|
||||||
webMarkupContainer.add(new PagingNavigator("pagingNavigator", dataView));
|
|
||||||
target.addComponent(webMarkupContainer);
|
|
||||||
target.addComponent(messageTextArea);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -257,28 +268,4 @@ public class ConferencePanel extends Panel {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNotification(final User user, final String message,
|
|
||||||
final NotificationPriority notificationPriority, final String absolutePath) {
|
|
||||||
|
|
||||||
Properties props = null;
|
|
||||||
try {
|
|
||||||
props = PropsUtils.load("notification.properties");
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
String mailSubject = props.getProperty("mailSubject");
|
|
||||||
String conferenceNotification = props.getProperty("conferenceNotification");
|
|
||||||
String twoNewLines = props.getProperty("twoNewLines");
|
|
||||||
|
|
||||||
String webNotificationMessage = SciProSession.get().getUser() + conferenceNotification
|
|
||||||
+ messageBoardModel.getObject().getTitle();
|
|
||||||
|
|
||||||
String mailMessage = webNotificationMessage + twoNewLines + message;
|
|
||||||
|
|
||||||
NotificationMessage notificationMessage = new NotificationMessage(webNotificationMessage,
|
|
||||||
mailSubject, mailMessage);
|
|
||||||
notificationController.processNotification(user, notificationMessage, absolutePath,
|
|
||||||
notificationPriority);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user