728x90
Fullcalendar ์ ์ฒดํ๋ฉด
<%@page import="bit.com.a.dto.CalendarPlugDto"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<link href="<%=request.getContextPath() %>/fcalLib/main.css" rel="stylesheet">
<script src="<%=request.getContextPath() %>/fcalLib/main.js"></script>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<style>
.body {
margin: 40px 10px;
padding: 0;
font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
font-size: 12px;
}
#calendar {
max-width: 900px;
margin: 0 auto;
}
</style>
<%
List<CalendarPlugDto> list = (List<CalendarPlugDto>)request.getAttribute("callist");
/*
for(CalendarPlugDto c : list){
System.out.println(c.toString());
}
*/
// JSONObject, JSONArray <-- java json
String events = "[";
for(CalendarPlugDto c : list){
events += "{ id:'" + c.getId() + "', title:'" + c.getTitle() + "', start:'" + c.getStartdate() + "', end:'" + c.getEnddate() + "', constraint:'" + c.getContent() + "',color:'" +c.getColor()+ "',seq:'"+c.getSeq()+"'},";
}
events = events.substring(0, events.lastIndexOf(","));
events += "]";
System.out.println(events);
request.setAttribute("events", events);
%>
<!--์นผ๋ ๋ ๋ฆฌ์คํธ -->
<div class="body">
<div id="calendar"></div>
</div>
Fullcalendar.js
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function () {
let calendarEl = document.getElementById('calendar');
let calendar = new FullCalendar.Calendar(calendarEl, {
headerToolbar: {
left: "prev,next today",
center: "title",
right: 'dayGridMonth,timeGridWeek,timeGridDay,listMonth'
},
initialDate: new Date(), // '2021-05-01', ์ฒ์ ์คํ์ ๊ธฐ๋ถ์ด ๋๋ ๋ ์ง
locale: 'ko', // ํ๊ธ์ค์
navLinks: true,
businessHours: true,
events:<%=request.getAttribute("events") %>
<%-- <%=request.getAttribute("events") %> --%>
});
calendar.render(); // rendering
calendar.on("dateClick", function (info) {
//alert('dateClick');
$('#exampleModal').modal('show');
});
//ํด๋ฆญ์ ๋ํ
์ผ ํ๋ฉด
calendar.on("eventClick", function(info) {
//alert(info.event.seq);
$('#datail').modal('show');
$('#d_title').val(info.event.title);
$('#d_id').val(info.event.id);
$('#d_content').val(info.event.constraint);
$('#d_start').val(info.event.start);
//์ฌ์ฉ์๊ฐ ์ข
๋ฃ๋ ์ง๋ฅผ ์
๋ ฅํ์ง ์์์
//์ข
๋ฃ๋ ์ง์ ์์๋ ์ง ์
๋ ฅ
if($("#d_end").val() == ""){
$('#d_end').val(info.event.start);
}else{
$('#d_end').val(info.event.end);
}
$('#d_laval').val();
});
});
$("#ajaxlist").click(function () {
$.ajax({
url: "Acalendarpluglist.do",
type: "GET",
cache: false,
dataType: "json",
data: $('#like_form').serialize(), //์์ด๋๊ฐ like_form์ธ ๊ณณ์ ๋ชจ๋ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์ ํ๋ผ๋ฏธํฐ ์ ์ก ํํ(ํ์ค ์ฟผ๋ฆฌํํ)๋ก ๋ง๋ค์ด์ค
success:
function(data){ //ajaxํต์ ์ฑ๊ณต์ ๋์ด์ค๋ ๋ฐ์ดํฐ ํต์งธ ์ด๋ฆ =data
var list = date;
},
error:
function (request, status, error){
alert("ajax์คํจ")
}
});
})
</script>
CALENDARPLUG TABLE
fcal jsํ์ผ ์์น
<link href="<%=request.getContextPath() %>/fcalLib/main.css" rel="stylesheet">
<script src="<%=request.getContextPath() %>/fcalLib/main.js"></script>
๋ชฉ๋ก ์ข์ธก ๋ฉ๋ด์ "์ผ์ ์ถ๊ฐ" ํด๋ฆญ์
ํ๋ฉด์ ํ๋์ง์๊ณ modal์ ์ฌ์ฉํ์ฌ ๊ทธ ํ์ด์ง์์ ์ฌ์ฉ์๊ฐ ์ผ์ ์ถ๊ฐ ๊ฐ๋ฅ
์ ๋ชฉ, ์บ๋ฆฐ๋์ ์ผ์ ์ ํ์ํ ์์, ์์๋ ์ง, ์ข ๋ฃ๋ ์ง, ๋ด์ฉ ์ถ๊ฐ๊ฐ๋ฅ
left-calendar.jsp
์ผ์ชฝ ๋ฉ๋ด์์ ์ผ์ ์ถ๊ฐ ๋๋ฅผ์ ๋ชจ๋ฌ๋ก ์ฐฝ ์์ฑ
<%@page import="java.util.Calendar"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.js"></script>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
Calendar cal = Calendar.getInstance();
int thour = cal.get(Calendar.HOUR_OF_DAY);
int tmin = cal.get(Calendar.MINUTE);
%>
<div class="menu_table">
<ul style="width: 100%">
<li class="title">์ผ์ ๊ด๋ฆฌ</li>
<li class="subtitle">์ผ์ </li>
<li class="menu_item">
<a href="calendarpluglist.do" title="์ผ์ ">์ผ์ ๋ชฉ๋ก</a>
</li>
<li class="menu_item">
<a href="#none" id = "insertDate" title="์ผ์ ์ถ๊ฐ" data-toggle="modal" data-target="#insertCal">์ผ์ ์ถ๊ฐ</a>
</li>
</ul>
</div>
<!-- ๋ชจ๋ฌ ์ฐฝ ํ
๋๋ฆฌ -->
<div class="modal fade" id="insertCal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<!-- ๋ชจ๋ฌ ๋ํ์ฐฝ ๋ณธ์ฒด-->
<div class="modal-dialog" role="document">
<!-- ๋ชจ๋ฌ ์ฝํ
์ธ ๋ถ๋ถ -->
<div class="modal-content">
<!-- ๋ชจ๋ฌ ํค๋ใผ -->
<div class="modal-header">
<!-- ๋ชจ๋ฌ ์ ๋ชฉ -->
<h5 class="modal-title" id="exampleModalLabel">์ผ์ ์ถ๊ฐ</h5>
<!-- ๋ซ๊ธฐ ์์ด์ฝ -->
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<!-- ๋ชจ๋ฌ ๋ณธ๋ฌธ -->
<div class="modal-body">
<form action="" id="_frm">
<table class = "list_table">
<col width="500"><col width="450">
<tr>
<th>ID</th>
<td>
${mem.id }
<input type = "hidden" name = "id" value = "${mem.id }">
</td>
</tr>
<tr>
<th>์ ๋ชฉ</th>
<td>
<input type = "text" size = "60" name = "title">
</td>
</tr>
<tr>
<th>๋ผ๋ฒจ ์์</th>
<td>
์ผ์ ์ ํ์ํ ๋ผ๋ฒจ ์์์ ๊ณ ๋ฅด์ธ์!
<select name = "color">
<option value="red">๋ ๋</option>
<option value="blue">๋ธ๋ฃจ</option>
<option value="orange">์ค๋ ์ง</option>
<option value="yellow">์๋ก์ฐ</option>
<option value="black">๋ธ๋</option>
</select>
</td>
</tr>
<tr><!--์ผ์ -->
<th>์ผ์ </th>
<td>
์์์ผ<input name="startdate" type="datetime-local" id="time-holder" value="" />
<br>
์ข
๋ฃ์ผ<input name="enddate" type="datetime-local" id="time-holder2" />
</tr><!--์ผ์ ๋ -->
<tr>
<th>๋ด์ฉ</th>
<td>
<textarea rows="20" cols="60" name = "content"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<input type="button" id = "_btnWrite" value = "์ผ์ ์ถ๊ฐ">
</td>
</tr>
</table>
</form>
</div>
<!-- ๋ชจ๋ฌ ๊ผฌ๋ฆฌ๋ง -->
<div class="modal-footer">
<!-- ๋ซ๊ธฐ ๋ฒํผ -->
<button type="button" class="btn btn-secondary" data-dismiss="modal">๋ซ๊ธฐ</button>
</div>
</div>
</div>
</div>
<script>
$("#_btnWrite").click(function () {
$("#_frm").attr("action","calplugwriteAf.do").submit();
});
//์ผ์ ์ถ๊ฐ์ ํ์ฌ์๊ฐ์ผ๋ก ์ค์
//https://hianna.tistory.com/319
$("#insertDate").click(function () {
document.getElementById('time-holder').value= new Date().toISOString().slice(0, 16);
document.getElementById('time-holder2').value= new Date().toISOString().slice(0, 16);
});
</script>
CalendarPlugController
package bit.com.a.controller;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import bit.com.a.dto.CalendarPlugDto;
import bit.com.a.dto.MemberDto;
import bit.com.a.service.CalendarPlugService;
@Controller
public class CalendarPlugController {
@Autowired
CalendarPlugService service;
@RequestMapping(value = "calendarpluglist.do", method = RequestMethod.GET)
public String calendarpluglist(Model model, HttpSession session) {
model.addAttribute("doc_title", "์ผ์ ๋ชฉ๋กplug");
//๋ก๊ทธ์ธ ์ธ์
์ ์ฅ
MemberDto dto = (MemberDto)session.getAttribute("login");
model.addAttribute("mem", dto);
//callist๋ฅผ ํ๊ธฐ์ํด cal ์ธ์คํด์ค ์ ์ธ
//์ผ์ ์ ์๊ธฐ๊ป๋ง ๋ณผ์์๋ค
CalendarPlugDto cal = new CalendarPlugDto();
cal.setId(dto.getId());
List<CalendarPlugDto> list = service.getCalendarPlugList(cal);
model.addAttribute("callist", list);
return "calendarpluglist.tiles";
}
@RequestMapping(value = "calplugwriteAf.do", method = RequestMethod.GET)
public String calwrtieAf(CalendarPlugDto dto) {
System.out.println("calplugwriteAf Controller");
boolean calwrite = service.addCal(dto);
if(calwrite) {
System.out.println("์ผ์ ์ด ์ฑ๊ณต์ ์ผ๋ก ์ถ๊ฐ๋์์ต๋๋ค");
return "redirect:/calendarpluglist.do";
}
return "redirect:/calendarpluglist.do";
}
}
'์คํ๋ง Spring > ๐งถ ์คํ๋ง ํ๋ ์์ํฌ Spring' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
์คํ๋ง Tiles๋ฅผ ํ์ฉํ ๊ฒ์ํ ์๋ฃ์ค ๋ง๋ค๊ธฐ (ํ์ผ ์ ๋ก๋) (0) | 2021.06.25 |
---|---|
์คํ๋ง Tiles๋ฅผ ํ์ฉํ ๊ฒ์ํ (์์ฑ, ์์ , ์ญ์ , ๋ํ ์ผ ) (0) | 2021.06.24 |
Spring ํ์ผ ์ ๋ก๋ (0) | 2021.06.24 |
์คํ๋ง Tiles๋ฅผ ํ์ฉํ ๊ฒ์ํ ๋ง๋ค๊ธฐ (๊ฒ์ํ ํ์ด์ง, ๊ฒ์) (0) | 2021.06.22 |
Spring Model ๊ฐ์ฒด๋ ๋ฌด์์ผ๊น? (0) | 2021.06.22 |
๋๊ธ