0
私のウェブサイトでは、投票を選択して投票の選択をするとコメント(写真)や音声(オプション)を送ることができます。すべてを送るクリックして投票を送信ラジオボタン
投票の形式は、特定の場所を検索した後に表示されます。
私は機能を変更したいと思います。投票をクリックした直後にすぐに保存され、後でいつものようにコメントや写真を送ることができるようにしたいと思います。
この
は私のフォームです:<script type="text/javascript">
\t $(".sinButtonVote > img").click(function(e){
\t $(this).parents("div.sinWebQuestion").addClass("voteChosen");
\t $("#sendVoteButton").removeClass("hidden");
\t $("#sendOpinion").removeClass("hidden");
});
$("div.sinBottomVoteButton").click(function(e){
$("#sendVoteButton").removeClass("hidden");
});
function afterOpinionSent() {
\t $("#wsCompany").val("Select Location").change();
\t }
</script>
<form th:action="@{/opinion/vote}"
enctype="multipart/form-data" method="post"
data-successHandler="afterOpinionSent"
class="s_ajaxForm">
\t <input type="hidden" name="webLocationId" th:value="${webLocation.id}" th:if="${webLocation!=null}"/>
\t <div th:each="webQuestion : ${webQuestions}" class="row WebQuestion">
\t \t <div class="col-sm-6">
\t \t \t <div th:text="${webQuestion.question}" class="sinButtonVoteLabel">Question?</div>
\t \t \t </div>
\t \t <div class="col-sm-6">
\t \t \t <label th:each="vote : ${ {3, 2, 1, 0} }" class="radio-inline ButtonVote">
\t \t \t \t <input type="radio" th:name="|questionVote[${webQuestion.id}]|" th:value="${vote}"/>
\t \t \t \t <img yada:src="@{|/res/img/question/${webQuestion.iconName+vote}.png|}" th:alt-title="|Voto ${vote}|">
\t \t \t </label>
\t \t </div>
\t \t </div>
\t <div style="text-align: center; margin-top: 15px;" id="sendOpinion" class="s_ajaxForm hidden">
\t \t <div style="float: left; width: 35%;" class="BottomVoteButton">
\t \t \t <label class="btn btn-default" data-toggle="collapse" data-target="#voteComment">
\t \t \t \t <img yada:src="@{/res/img/question/comment.png}" title="Comment">
\t \t \t \t <span>Opinion</span>
\t \t \t </label>
\t \t \t </div>
\t \t \t <div style="float: left; width: 30%;" class="BottomVoteButton">
\t \t <label class="btn btn-default btn-file">
\t \t <img yada:src="@{/res/img/question/photo.png}" height="35px" title="Photo"><br />
\t \t <span>Photo</span>
\t \t <input type="file" accept="image/*" capture="camera" class="hidden" name="photo">
\t \t </label> \t
\t \t </div>
\t \t <div style="overflow: hidden; width: auto;" class="BottomVoteButton">
\t \t \t <label class="btn btn-default btn-file">
\t \t \t \t <img yada:src="@{/res/img/question/Audio.png}" title="Audio">
\t \t \t \t <span>Audio</span>
\t \t \t \t <input type="file" accept="audio/*" capture="microphone" class="hidden" name="audio">
\t \t \t </label>
\t \t </div>
\t <div id="voteComment" class="collapse" th:if="${webLocation!=null}">
\t <div class="form-group">
\t \t <textarea class="form-control" rows="5" maxlength="1024" name="comment" placeholder="Comment..."></textarea>
\t \t </div>
\t </div>
</div>
<button id="sendVoteButton" type="submit" class="s_ajaxForm btn btn-default btn-block hidden">Send</button>
</form>
そして、これは私のopinionController.javaです:私はCを変更するにはどうすればよい
@RequestMapping("/vote") // Ajax
\t public String voto(FormOpinioni formOpinioni, HttpServletRequest request, HttpServletResponse response, Model model) {
\t \t WebLocation webLocation = null;
\t \t if (formOpinioni.getWebLocationId() != null) {
\t \t \t webLocation = webLocationRepository.findOne(formOpinioni.getWebLocationId());
\t \t }
\t \t if (webLocation==null) {
\t \t \t return "/yada/ajaxError";
\t \t }
\t \t
\t \t YadaBrowserId yadaBrowserId = yadaBrowserIdDao.ensureYadaBrowserId(COOKIE_UUIDNAME, COOKIE_EXPIRATIONSEC, request, response);
\t \t
\t \t // Save WebResult
\t \t String ipAddress = request.getRemoteAddr();
\t \t for (Map.Entry<Long,String> idAndVote : formOpinioni.getQuestionVote().entrySet()) {
\t \t \t long questionId = idAndVote.getKey();
\t \t \t int vote = Integer.parseInt(idAndVote.getValue());
\t \t \t boolean stored = webResultDao.storeResult(questionId, vote, yadaBrowserId, ipAddress);
\t \t }
\t \t
\t \t // Save il comment
\t \t String commento = formOpinioni.getCommento();
\t \t if (!StringUtils.isBlank(comment) && webLocation.isEnabled()) {
\t \t \t boolean stored = webAttachmentDao.storeAttachment(WebAttachment.TYPE_COMMENT, comment, ipAddress, webLocation, yadaBrowserId);
\t \t }
\t \t // Save photo
\t \t saveUpload(WebAttachment.TYPE_IMAGE, formOpinioni.getPhoto(), webLocation, yadaBrowserId, ipAddress, response, model);
\t \t
\t \t // Save audio
\t \t saveUpload(WebAttachment.TYPE_AUDIO, formOpinioni.getAudio(), webLocation, yadaBrowserId, ipAddress, response, model);
\t \t
\t \t return thanksForOpinion("Registered opiniono", model);
\t }
\t
\t private String thanksForOpinion(String title, Model model) {
\t \t return YadaNotify.instance(model)
\t \t \t \t .yadaOk().yadaAutoclose(2000)
\t \t \t \t .yadaTitle(title)
\t \t \t \t .yadaMessage("<p style='text-align:center; min-height:60px;'>Thanks You for opinion</p>")
\t \t \t \t .yadaSave();
\t }
オデ?