How to use one form and action class on multiple pages JSP - struts-1

How to use same form beans and action class on multiple pages? do i need to create one form bean and action class that exactly have same variable for other JSP pages? thanks in advance. How to use those form and action class in Dashboard.jsp? i just want to display data of vendor in dashboard.jsp.
below is example code:
VendorInfoForm.java
package com.pms.reference;
import com.base.utility.DateUtil;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
public class VendorInfoForm extends org.apache.struts.action.ActionForm {
private String vivendorID;
private String vivendorShortname;
private String vivendorName;
public String getVivendorID() {
return vivendorID;
}
public void setVivendorID(String vivendorID) {
this.vivendorID = vivendorID;
}
public String getVivendorName() {
return vivendorName;
}
public void setVivendorName(String vivendorName) {
this.vivendorName = vivendorName;
}
public String getVivendorShortname() {
return vivendorShortname;
}
public void setVivendorShortname(String vivendorShortname) {
this.vivendorShortname = vivendorShortname;
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
return errors;
}
}
VendorInfoAction.java
package com.pms.reference;
import com.base.constant.MessageConstant;
import com.base.utility.BaseUtil;
import com.base.utility.DateUtil;
import com.hbs.base.entities.ComAccessLevel;
import com.hbs.base.entities.ComUserProfiles;
import com.hbs.base.entities.ComAccessLevel;
import com.htp.web.base.BaseAction;
import com.htp.web.base.constant.PageConstant;
import com.htp.web.utility.WebUtil;
import com.pms.reference.entities.ASVendorInfo;
import com.pms.reference.entities.HDPersonInfo;
import com.pms.reference.entities.RefState;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class VendorInfoAction extends BaseAction {
private final static String JSP_LIST = "/jspNew/pms/reference/VendorInfoList.jsp";
private final static String JSP_CREATE = "/jspNew/pms/reference/VendorInfoCreate.jsp";
private final static String JSP_READ = "/jspNew/pms/reference/VendorInfoRead.jsp";
private final static String JSP_UPDATE = "/jspNew/pms/reference/VendorInfoUpdate.jsp";
public ActionForward executeAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
VendorInfoForm formBean = (VendorInfoForm)form;
String action = WebUtil.getStrInput(request, "hdAction");
String nextJSP = "";
try {
if (BaseUtil.isEqualsCaseIgnore(action, PageConstant.MENU) ||
BaseUtil.isEqualsCaseIgnore(action, PageConstant.LIST) ||
BaseUtil.isEqualsCaseIgnore(action, PageConstant.GET_SORTING)) {
nextJSP = getList(request, action);
}
else if (BaseUtil.isEqualsCaseIgnore(action, PageConstant.GET_CREATE)) {
nextJSP = getCreate(request, action);
}
else if (BaseUtil.isEqualsCaseIgnore(action, PageConstant.CREATE) ||
BaseUtil.isEqualsCaseIgnore(action, PageConstant.UPDATE)) {
nextJSP = doCreateOrUpdate(request, action, formBean);
}
else if (BaseUtil.isEqualsCaseIgnore(action, PageConstant.DELETE)) {
nextJSP = doDelete(request, action);
}
else if (BaseUtil.isEqualsCaseIgnore(action, PageConstant.GET_READ)
|| BaseUtil.isEqualsCaseIgnore(action, PageConstant.GET_UPDATE)) {
nextJSP = getReadOrUpdate(request, action);
}
}
catch(Exception e){
e.getMessage();
}
return new ActionForward(nextJSP);
}
private String getList(HttpServletRequest request, String action) throws Exception{
ComUserProfiles profile = (ComUserProfiles)request.getSession().getAttribute("PROFILE");
lookupComAccessLevel();
ComAccessLevel accessLevel = comAccessLevelFacade.find(profile.getAclId());
request.setAttribute("accessLevel", accessLevel);
String input = WebUtil.getStrInput(request, "txtSchAll");
input = BaseUtil.replaceQuickSearch(input);// modified by din 20/05/2015
String pageNo = WebUtil.getStrInput(request, "hdPgNo");
String sortOrder = "";
String sortId = WebUtil.getStrInput(request, "sortId");
if (BaseUtil.isEqualsCaseIgnore(action, PageConstant.MENU)) {
manageCommonSession(request, "Vendor");
}
// ----------------- Start Sorting -------------//
manageSortingSession(request, sortId);
sortId = BaseUtil.getStr(request.getSession().getAttribute("sortingId"));
sortOrder = BaseUtil.getStr(request.getSession().getAttribute("sortingOrder"));
// ------------------ End Sorting --------------//
Integer maxNo = BaseUtil.getInt(request.getSession().getAttribute("DISPLAY"));
Integer firstNo = ((pageNo!=null && !pageNo.equalsIgnoreCase("")?Integer.parseInt(pageNo):1) - 1) * maxNo;
lookupASVendorInfo();
int[] range = new int[]{firstNo, maxNo};
List<ASVendorInfo> list = aSVendorInfo.findAll(input, range, sortId, sortOrder);
int totalRecord = aSVendorInfo.findTotal(input);
request.setAttribute("list", list);
request.setAttribute("currentpageno", pageNo);
request.setAttribute("totalrecords", String.valueOf(totalRecord));
request.setAttribute("noofpages", String.valueOf(totalRecord / range[1] + (totalRecord % range[1] == 0 ? 0 : 1)));
request.setAttribute("recordstartno", firstNo);
request.setAttribute("searchinput", input);
return JSP_LIST;
}
private String getCreate(HttpServletRequest request, String action) throws Exception{
if (BaseUtil.isEqualsCaseIgnore(action, PageConstant.MENU)) {
manageCommonSession(request, "Vendor");
}
lookupHDPersonInfo();
List<HDPersonInfo> personList = hDPersonInfo.findAllByPersonType("3");
request.setAttribute("personList", personList);
lookupRefState();
List<RefState> stateList = refStateFacade.findAll();
request.setAttribute("stateList", stateList);
return JSP_CREATE;
}
private String doCreateOrUpdate(HttpServletRequest request, String action, VendorInfoForm src) throws Exception{
ComUserProfiles profile = (ComUserProfiles)request.getSession().getAttribute("PROFILE");
String msgInfo = "";
String msgType = "";
ASVendorInfo dest = new ASVendorInfo();
BeanUtils.copyProperties(dest, src);
try {
msgType = MessageConstant.SUCCESS;
lookupASVendorInfo();
if(BaseUtil.isEqualsCaseIgnore(action, PageConstant.UPDATE)){
dest.setVivendorShortname(BaseUtil.getStrUpper(src.getVivendorShortname()));
dest.setViAddress1(BaseUtil.getStrUpper(src.getViAddress1()));
dest.setViAddress2(BaseUtil.getStrUpper(src.getViAddress2()));
dest.setViAddress3(BaseUtil.getStrUpper(src.getViAddress3()));
dest.setViUpdateDate(new Date(DateUtil.getCurrentDateTime()));
dest.setViUpdateId(profile.getId());
dest.setViActiveSts(BaseUtil.getStr(src.getViActiveSts()));
aSVendorInfo.edit(dest);
msgInfo = MessageConstant.RECORD_UPDATE_SUCCESS + ". <a href=\""+request.getContextPath()+"/VendorInfo.do?hdAction=getRead&id=" + dest.getVivendorID() + "\" data-toggle=\"ajaxModal\" >View Here.</a>";
}
else {
dest.setVivendorID("");
dest.setVivendorShortname(BaseUtil.getStrUpper(src.getVivendorShortname()));
dest.setViAddress1(BaseUtil.getStrUpper(src.getViAddress1()));
dest.setViAddress2(BaseUtil.getStrUpper(src.getViAddress2()));
dest.setViAddress3(BaseUtil.getStrUpper(src.getViAddress3()));
dest.setViCreateDate(new Date(DateUtil.getCurrentDateTime()));
dest.setViCreateId(profile.getId());
dest.setViActiveSts(BaseUtil.getStr(src.getViActiveSts()));
String vendorId = aSVendorInfo.createVendorInfo(dest);
msgInfo = MessageConstant.RECORD_CREATE_SUCCESS + ". <a href=\""+request.getContextPath()+"/VendorInfo.do?hdAction=getRead&id=" + vendorId + "\" data-toggle=\"ajaxModal\" >View Here.</a>";
}
} catch(Exception e) {
msgType = MessageConstant.ERROR;
e.printStackTrace();
if(BaseUtil.isEqualsCaseIgnore(action, PageConstant.UPDATE)) {
msgInfo = MessageConstant.RECORD_UPDATE_FAILED;
}
else {
msgInfo = MessageConstant.RECORD_CREATE_FAILED;
}
}
request.setAttribute("errMsg", BaseUtil.getMessage(msgType, msgInfo));
return getList(request, action);
}
private String getReadOrUpdate(HttpServletRequest request, String action) throws Exception{
String id = WebUtil.getStrInput(request, "id");
if (BaseUtil.isEqualsCaseIgnore(action, PageConstant.MENU)) {
manageCommonSession(request, "Vendor");
}
lookupHDPersonInfo();
List<HDPersonInfo> personList = hDPersonInfo.findAllByPersonType("3");
request.setAttribute("personList", personList);
lookupRefState();
List<RefState> stateList = refStateFacade.findAll();
request.setAttribute("stateList", stateList);
lookupASVendorInfo();
ASVendorInfo o = aSVendorInfo.find(id);
request.setAttribute("obj", o);
if (BaseUtil.isEqualsCaseIgnore(action, PageConstant.GET_UPDATE)) {
return JSP_UPDATE;
}
else {
return JSP_READ;
}
}
private String doDelete(HttpServletRequest request, String action) throws Exception{
String id = WebUtil.getStrInput(request, "id");
lookupASVendorInfo();
ASVendorInfo o = aSVendorInfo.find(id);
aSVendorInfo.remove(o);
return getList(request, action);
}
#Override
protected void manageCommonSession(HttpServletRequest request, String formName) throws Exception {
request.getSession().removeAttribute("sortingOrder");
request.getSession().removeAttribute("sortingId");
request.getSession().removeAttribute("formName");
request.getSession().removeAttribute("menuId");
request.getSession().removeAttribute("txnId");
request.getSession().setAttribute("formName", formName);
request.getSession().setAttribute("menuId", WebUtil.getStrInput(request, "menuId"));
request.getSession().setAttribute("txnId", WebUtil.getStrInput(request, "txnId"));
}
}
Dashboard.jsp
<%#page import="com.htp.web.base.constant.PageConstant"%>
<%#page import="org.json.JSONObject"%>
<%--# page language="java" contentType="application/json; charset=UTF-8" pageEncoding="UTF-8"--%>
<%#page import="com.pms.reference.entities.HDCaseMaster"%>
<%#page import="java.util.List"%>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<%#page import="com.hbs.base.entities.ComUserProfiles"%>
<%#page import="com.base.utility.BaseUtil"%>
<%
String userID = "";
HDCaseMaster o = (HDCaseMaster) request.getAttribute("obj");
if (o == null) {
o = new HDCaseMaster();
}
ComUserProfiles profile = (ComUserProfiles) request.getSession().getAttribute("PROFILE");
List<HDCaseMaster> masterList = (List) request.getSession().getAttribute("masterList");
if (profile != null) {
if (!profile.equals("")) {
userID = profile.getId();
}
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<ul class="breadcrumb no-border no-radius b-b b-light pull-in">
<li><i class="fa fa-home"></i> Dashboard</li>
</ul>
<!--<content-page></content-page>-->
<div class="m-b-md">
<h3 class="m-b-none">Dashboard</h3>
<small>Welcome back, <%=BaseUtil.getStr(profile.getNickName())%></small> </div>
<%
JSONObject json = new JSONObject();
json.put("city", "Mumbai");
json.put("country", "India");
%>
<%=json.toString()%>
<%=o.getCmStatus()%>
<section class="panel panel-default">
<div class="row m-l-none m-r-none bg-light lter">
<div class="col-sm-4 col-md-4 padder-v b-r b-light min-box-height"> <span class="fa-stack fa-2x pull-left m-r-sm"> <i class="fa fa-circle fa-stack-2x text-info"></i> <i class="fa fa-user fa-stack-1x text-white"></i> </span> <a class="clear" href="javascript:getMenuPage('/CaseMaster.do?hdAction=getStartPage&menuId=M0302&txnId=M03T02');"> <span class="h3 block m-t-xs"><strong>Incident</strong></span> <small class="text-muted text-uc">Add New Incident</small> </a> </div>
<div class="col-sm-4 col-md-4 padder-v b-r b-light min-box-height"> <span class="fa-stack fa-2x pull-left m-r-sm"> <i class="fa fa-circle fa-stack-2x text-info"></i> <i class="fa fa-tasks fa-stack-1x text-white"></i> </span> <a class="clear" href="javascript:getMenuPage('/SLA.do?hdAction=getStartPage&menuId=M0402&txnId=M04T02');"> <span class="h3 block m-t-xs"><strong>SLA</strong></span> <small class="text-muted text-uc">Add New SLA</small> </a> </div>
<div class="col-sm-4 col-md-4 padder-v b-r b-light min-box-height"> <span class="fa-stack fa-2x pull-left m-r-sm"> <i class="fa fa-circle fa-stack-2x text-info"></i> <i class="fa fa-edit fa-stack-1x text-white"></i> </span> <a class="clear" href="javascript:getMenuPage('/GenReport.do?hdAction=getStartPage&menuId=M0502&txnId=M05T02');"> <span class="h3 block m-t-xs"><strong>Report</strong></span> <small class="text-muted text-uc">Incident Report</small> </a> </div>
</div>
</section>
<div class="row">
<div class="col-md-12"> <!-- .crousel slide -->
<section class="panel panel-default">
<div class="carousel slide auto panel-body" id="c-slide">
<ol class="carousel-indicators out">
<li data-target="#c-slide" data-slide-to="0" class="active"></li>
<li data-target="#c-slide" data-slide-to="1" class=""></li>
<li data-target="#c-slide" data-slide-to="2" class=""></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<p class="text-center"> <em class="h4 text-mute">Save your time</em><br>
<small class="text-muted">Many components</small> </p>
</div>
<div class="item">
<p class="text-center"> <em class="h4 text-mute">Nice and easy to use</em><br>
<small class="text-muted">Full documents</small> </p>
</div>
<div class="item">
<p class="text-center"> <em class="h4 text-mute">Mobile header first</em><br>
<small class="text-muted">Mobile/Tablet/Desktop</small> </p>
</div>
</div>
<a class="left carousel-control" href="#c-slide" data-slide="prev"> <i class="fa fa-angle-left"></i> </a> <a class="right carousel-control" href="#c-slide" data-slide="next"> <i class="fa fa-angle-right"></i> </a> </div>
</section>
<!-- / .carousel slide --> </div>
</div>
<div class="row">
<div class="col-md-12">
<section class="panel panel-default portlet-item">
<header class="panel-heading bg-primary"> News </header>
<section class="panel-body">
<article class="media"> <span class="pull-left thumb-sm"><img src="../../images/avatar_default.jpg" class="img-circle"></span>
<div class="media-body">
<div class="pull-right media-xs text-center text-muted"> <strong class="h4">12:18</strong><br>
<small class="label bg-light">pm</small> </div>
Bootstrap 3 released <small class="block">John Smith <span class="label label-success">Circle</span></small> <small class="block m-t-sm">Sleek, intuitive, and powerful mobile-first front-end framework for faster and easier web development.</small> </div>
</article>
<div class="line pull-in"></div>
<article class="media"> <span class="pull-left thumb-sm"><i class="fa fa-file-o fa-3x icon-muted"></i></span>
<div class="media-body">
<div class="pull-right media-xs text-center text-muted"> <strong class="h4">17</strong><br>
<small class="label bg-light">feb</small> </div>
Bootstrap documents <small class="block">John Smith <span class="label label-info">Friends</span></small> <small class="block m-t-sm">There are a few easy ways to quickly get started with Bootstrap, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.</small> </div>
</article>
<div class="line pull-in"></div>
<article class="media">
<div class="media-body">
<div class="pull-right media-xs text-center text-muted"> <strong class="h4">09</strong><br>
<small class="label bg-light">jan</small> </div>
Mobile first html/css framework <small class="block m-t-sm">Bootstrap, Ratchet</small> </div>
</article>
</section>
</section>
</div>
</div>
<div class="row">
<div class="col-md-12">
<section class="panel panel-default">
<header class="panel-heading font-bold">Incident Logs Created This Month</header>
<div class="panel-body">
<div class="row text-sm wrapper">
<div class="col-sm-12 m-b-xs text-center">
<div class="btn-group m-b" data-toggle="buttons">
<label class="btn btn-sm btn-default active btn-info">
<input type="radio" name="options" id="btnMonth">
Month </label>
<label class="btn btn-sm btn-default btn-info">
<input type="radio" name="options" id="btnWeek">
Week </label>
</div>
</div>
<div id="flot-test" style="height:265px"></div>
<!--<div id="namaHari"></div>-->
</div>
</div>
<footer class="panel-footer bg-white no-padder">
<%--<%=masterListDisplay %>--%>
<%
// int count [] = new int [5];
// if(masterListDisplay != null){
// for(HDCaseMaster o : masterListDisplay ){
// if(BaseUtil.isEquals(BaseUtil.getStr(o.getCmStatus()), "4")){count[0]=count[0]+1;}
// else if(BaseUtil.isEquals(BaseUtil.getStr(o.getCmStatus()), "5")){count[1]=count[1]+1;}
// else if(BaseUtil.isEquals(BaseUtil.getStr(o.getCmStatus()), "6")){count[2]=count[2]+1;}
// else if(BaseUtil.isEquals(BaseUtil.getStr(o.getCmStatus()), "7")){count[3]=count[3]+1;}
// else
// count[4]=count[4]+1;
// }
// }
%>
<div class="row text-center no-gutter">
<div class="col-xs-3 b-r b-light btn-success">
<span class="h4 font-bold m-t block">
</span> <small class="text-white m-b block ">Open Logs<div id="openLog"></div></small> </div>
<div class="col-xs-3 b-r b-light btn-warning"> <span class="h4 font-bold m-t block">System.out.print(GetTotalLog())</span> <small class="text-white m-b block ">Resolved Logs</small> </div>
<div class="col-xs-3 b-r b-light btn-info"> <span class="h4 font-bold m-t block">System.out.print(GetTotalLog())</span> <small class="text-white m-b block ">Closed Logs</small> </div>
<div class="col-xs-3 btn-danger"> <span class="h4 font-bold m-t block">System.out.print(GetTotalLog())</span> <small class="text-white m-b block ">Duplicate/Cancel Logs</small> </div>
</div>
</footer>
</section>
</div>
</div>
<div class="row">
<div class="col-md-8">
<section class="panel panel-default">
<header class="panel-heading font-bold">Total Incident Logs Created by Month</header>
<div class="panel-body">
<div id="flot-bar" style="height:150px"></div>
</div>
</section>
</div>
<div class="col-md-4">
<section class="panel panel-default">
<header class="panel-heading font-bold">Data By Day</header>
<div class="bg-light dk wrapper"> <span class="pull-right">Wednesday</span> <span class="h4">07-11-2014<br>
<small class="text-muted"></small> </span>
<div class="text-center m-b-n m-t-sm">
<div class="sparkline" data-type="line" data-height="65" data-width="100%" data-line-width="2" data-line-color="#dddddd" data-spot-color="#bbbbbb" data-fill-color="" data-highlight-line-color="#fff" data-spot-radius="3" data-resize="true" values="280,320,220,385,450,320,345,250,250,250,400,380"></div>
<br/>
</div>
</div>
<div class="panel-body">
<div> <span class="text-muted">Total:</span> <span class="h3 block">53 <small class="text-muted">log(s) created</small></span> </div>
</div>
</section>
</div>
</div>
<div class="row">
<div class="col-md-4">
<section class="panel b-light">
<header class="panel-heading bg-primary no-border"><strong>Calendar</strong></header>
<div id="calendar" class="bg-primary-lt m-l-n-xxs m-r-n-xxs"></div>
<div class="list-group"> <span class="badge bg-danger">7:30</span> Meet a friend <span class="badge bg-success">9:30</span> Have a kick off meeting with .inc company <span class="badge bg-light">19:30</span> Milestone release </div>
</section>
</div>
</div>

Related

Laravel components. How to check a props when it is not informed in the component

I'm trying to figure out how to do a check on the /props variable if it hasn't been passed.
For example, in my component, I have some props to check true or false. If I don't pass these props on to the component, it throws an error.
Can anyone tell me how to check this?
I will give an example below in code.
<x-banner-introduction titleBefore="Blog" titleAfter="A voz do cliente" description="Lorem ipsum dolor sit amet consectetur adipisicing elit. Culpa, velit?" btnText="Confira aqui" btnUrl="/" hasSearchField="true" hasLikeShare="" class="mb-12">
</x-banner-introduction>
<section {{ $attributes->merge(['class' => 'c-bannerIntroduction']) }}>
<div class="container">
#if($isCarousel)
<p>é carrossel</p>
#endif
#if($titleAfter)
<h1 class="nv-title nv-title--smile nv-title--big text-white mb-3 mb-md-4">
<span>{{$titleBefore}}</span>
<img src="{{asset('/images/icons/smile--white.svg')}}" alt="Ícone sorriso">
<strong>{{$titleAfter}}</strong>
</h1>
#else
<h1 class="nv-title nv-title--smile nv-title--big text-white mb-3 mb-md-4">
<strong>{{$titleBefore}}</strong>
</h1>
#endif
#if($description)
<div class="row mb-7">
<div class="col col-12 col-lg-5">
<p class="nv-text--description text-white">
{{ $description ?? null }}
</p>
</div>
</div>
#endif
#if($btnText)
<a href="{{$btnUrl}}" class="nv-btn nv-btn--small">
{{$btnText}}
</a>
#endif
#if($hasSearchField === "true")
<form class="c-bannerIntroduction__divSearch c-form mt-10">
<div class="row">
<div class="col">
<fieldset class="c-form__formGroup">
<label class="c-form__formGroup__label d-none d-md-block" for="inputSearch">O que deseja
encontrar?</label>
<input class="c-form__formGroup__input d-none d-md-block" type="search" id="inputSearch"
placeholder="Digite palavras chaves" minlength="3" maxlength="255" required>
<input class="c-form__formGroup__input d-block d-md-none" type="search" id="inputSearch"
placeholder="O que deseja encontrar?" minlength="3" maxlength="255" required>
</fieldset>
</div>
<div class="col col-auto">
<button class="c-form__submitBtn nv-btn nv-btn--search">
<span>Buscar</span>
</button>
</div>
</div>
</form>
#endif
#if($hasLikeShare === 'true')
<div class="c-bannerIntroduction__likesSharesInfo mt-6">
<div class="row">
<div class="col col-12 col-md-6 mb-2 mb-md-0">
<div class="c-bannerIntroduction__likesSharesInfo__info">
<div class="row align-content-center">
<div class="c-bannerIntroduction__likesSharesInfo__info__colImage col col-auto pr-0">
<img src="{{asset('/images/models/homem-branco-oculos-blusa-preta.jpeg')}}" class="c-bannerIntroduction__likesSharesInfo__info__colImage__illustrativePicture" alt="Imagem ilustrativa">
</div>
<div class="c-bannerIntroduction__likesSharesInfo__info__colImage col col-auto px-0">
<img src="{{asset('/images/models/homem-branco-oculos-blusa-preta.jpeg')}}" class="c-bannerIntroduction__likesSharesInfo__info__colImage__illustrativePicture" alt="Imagem ilustrativa">
</div>
<div class="c-bannerIntroduction__likesSharesInfo__info__colImage col col-auto px-0">
<img src="{{asset('/images/models/homem-branco-oculos-blusa-preta.jpeg')}}" class="c-bannerIntroduction__likesSharesInfo__info__colImage__illustrativePicture" alt="Imagem ilustrativa">
</div>
<div class="c-bannerIntroduction__likesSharesInfo__info__colImage col col-auto px-0">
<img src="{{asset('/images/models/homem-branco-oculos-blusa-preta.jpeg')}}" class="c-bannerIntroduction__likesSharesInfo__info__colImage__illustrativePicture" alt="Imagem ilustrativa">
</div>
<div class="c-bannerIntroduction__likesSharesInfo__info__colImage col col-auto px-0">
<img src="{{asset('/images/icons/heart--bgWhite--gray.svg')}}" class="c-bannerIntroduction__likesSharesInfo__info__colImage__illustrativePicture" alt="Ícone de coração">
</div>
<div class="col pl-2">
<div class="h-100 d-flex align-items-center">
<p class="c-bannerIntroduction__likesSharesInfo__info__text">
Amado e curtido por <strong>50 visitantes</strong>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="col col-12 col-md-6">
<div class="c-bannerIntroduction__likesSharesInfo__info">
<div class="row align-content-center">
<div class="c-bannerIntroduction__likesSharesInfo__info__colImage col col-auto pr-0">
<img src="{{asset('/images/models/homem-branco-oculos-blusa-preta.jpeg')}}" class="c-bannerIntroduction__likesSharesInfo__info__colImage__illustrativePicture" alt="Imagem ilustrativa">
</div>
<div class="c-bannerIntroduction__likesSharesInfo__info__colImage col col-auto px-0">
<img src="{{asset('/images/models/homem-branco-oculos-blusa-preta.jpeg')}}" class="c-bannerIntroduction__likesSharesInfo__info__colImage__illustrativePicture" alt="Imagem ilustrativa">
</div>
<div class="c-bannerIntroduction__likesSharesInfo__info__colImage col col-auto px-0">
<img src="{{asset('/images/models/homem-branco-oculos-blusa-preta.jpeg')}}" class="c-bannerIntroduction__likesSharesInfo__info__colImage__illustrativePicture" alt="Imagem ilustrativa">
</div>
<div class="c-bannerIntroduction__likesSharesInfo__info__colImage col col-auto px-0">
<img src="{{asset('/images/models/homem-branco-oculos-blusa-preta.jpeg')}}" class="c-bannerIntroduction__likesSharesInfo__info__colImage__illustrativePicture" alt="Imagem ilustrativa">
</div>
<div class="c-bannerIntroduction__likesSharesInfo__info__colImage col col-auto px-0">
<img src="{{asset('/images/icons/share--bgWhite--gray.svg')}}" class="c-bannerIntroduction__likesSharesInfo__info__colImage__illustrativePicture" alt="Ícone de coração">
</div>
<div class="col pl-2">
<div class="h-100 d-flex align-items-center">
<p class="c-bannerIntroduction__likesSharesInfo__info__text">
Amado e compartilhado por <strong>80 visitantes</strong>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
#endif
</div>
{{$slot}}
</section>
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class BannerIntroduction extends Component
{
/**
* Create a new component instance.
*
* #return void
*/
public $isCarousel;
public $titleBefore;
public $titleAfter;
public $description;
public $btnText;
public $btnUrl;
public $hasSearchField;
public $hasLikeShare;
public function __construct($isCarousel, $titleBefore, $titleAfter, $description, $btnText, $btnUrl, $hasSearchField, $hasLikeShare)
{
$this->isCarousel = $isCarousel ? $isCarousel : 0;
$this->titleBefore = $titleBefore;
$this->titleAfter = $titleAfter;
$this->description = $description;
$this->btnText = $btnText;
$this->btnUrl = $btnUrl;
$this->hasSearchField = $hasSearchField;
$this->hasLikeShare = $hasLikeShare;
}
/**
* Get the view/contents that represent the component.
*
* #return \Illuminate\View\View|string
*/
public function render()
{
return view('components.banner-introduction');
}
}
In the example above, 'Carousel' is not passing, so it gives an error on the page.
Error:
Illuminate\Contracts\Container\BindingResolutionException
Unresolvable dependency resolving [Parameter #0 [ <required> $isCarousel ]] in class App\View\Components\BannerIntroduction (View: C:\programming\gitlab\Smiles\766-desafio-cx\resources\views\home.blade.php)
You can just add the default value to 0 for the $isCarousel param so that even if you didn't pass a value it will not throw an error. You also don't have to add a condition.
public function __construct($isCarousel = 0, ...)
{
$this->isCarousel = $isCarousel;
}
Did you try using isset($prop)?
For example:
instead of
#if($btnText)
<a href="{{$btnUrl}}" class="nv-btn nv-btn--small">
{{$btnText}}
</a>
#endif
You can try
#if(isset($btnText))
<a href="{{$btnUrl}}" class="nv-btn nv-btn--small">
{{$btnText}}
</a>
#endif

search in PHP Array, similar to MySQL Like %var% search with livewire

I saw other questions that usually use preg_grep but my problem was not solved
In the LiveWire component, I receive information from the web service and display it in a table.
Now the user does the search and I want to display the items that look like the searched phrase
I wrote the code like this:
class Cryptolist extends Component
{
use WithPagination;
public bool $loadData = false;
protected $paginationTheme = 'bootstrap';
public $perPage = 10;
public $search = '';
public function init()
{
$this->loadData = true;
}
public function getBalance($asset)
{
$this->dispatchBrowserEvent('setPrice' ,[
'asset' => $asset,
'price' => getCryptoBalance($asset)
]);
}
public function setPerPage(int $page)
{
$this->perPage = $page;
}
public function render()
{
try {
if ($this->loadData == true) {
$api = new \Binance\API('','');
$coins = $api->coins();
} else {
$coins = [];
}
return view('livewire.backend.crypto.cryptolist')->with('coins' , collect(preg_grep('~'.$this->search.'~i', $coins))->paginate($this->perPage));
}catch(\Exception $e)
{
return view('wrong')->with('e' , $e);
}
}
}
and this is view:
<div class="nk-block" id="loadesh1" >
<div class="card card-bordered card-stretch">
<div class="card-inner-group">
<div class="card-inner position-relative card-tools-toggle">
<div class="card-title-group">
<div class="card-tools mr-n1">
<ul class="btn-toolbar gx-1">
<li>
<a class="btn btn-icon search-toggle toggle-search" data-target="search" href="#"><em class="icon ni ni-search"></em></a>
</li>
<li class="btn-toolbar-sep"></li>
<li>
<div class="toggle-wrap">
<a class="btn btn-icon btn-trigger toggle" data-target="cardTools" href="#"><em class="icon ni ni-menu-right"></em></a>
<div class="toggle-content" data-content="cardTools">
<ul class="btn-toolbar gx-1">
<li class="toggle-close">
<a class="btn btn-icon btn-trigger toggle" data-target="cardTools" href="#"><em class="icon ni ni-arrow-left"></em></a>
</li>
<li>
<div class="dropdown">
<a class="btn btn-trigger btn-icon dropdown-toggle" data-toggle="dropdown" href="#"><em class="icon ni ni-setting"></em></a>
<div class="dropdown-menu dropdown-menu-xs dropdown-menu-right">
<ul class="link-check">
<li><span>show</span></li>
<li #if($perPage === 10) class="active" #endif>
10
</li>
<li #if($perPage === 20) class="active" #endif>
20
</li>
<li #if($perPage === 50) class="active" #endif>
50
</li>
</ul>
</div>
</div>
</li>
</ul>
</div>
</div>
</li>
</ul>
</div>
</div>
<div class="card-search search-wrap" data-search="search">
<div class="card-body">
<div class="search-content">
<a class="search-back btn btn-icon toggle-search" data-target="search" href="#"><em class="icon ni ni-arrow-left"></em></a><input wire:model="search" class="form-control border-transparent form-focus-none" placeholder="type for search" type="text"><button class="search-submit btn btn-icon"><em class="icon ni ni-search"></em></button>
</div>
</div>
</div>
</div>
<div class="card-inner p-0" wire:init="init">
<div class="nk-tb-list nk-tb-ulist">
<div class="nk-tb-item nk-tb-head">
<div class="nk-tb-col">
<span class="sub-text">name</span>
</div>
<div class="nk-tb-col tb-col-mb">
<span class="sub-text">balance</span>
</div>
</div>
#foreach ($coins as $item => $value)
<div class="nk-tb-item">
<div class="nk-tb-col">
<a href="/demo5/user-details-regular.html">
<div class="user-card">
<div class="user-avatar d-none d-sm-flex">
#if(file_exists(public_path() . '/img/crypto/'.strtolower($value['coin'].".svg")))
<img style="border-radius: 0" src="{{asset('/img/crypto/'.strtolower($value['coin']))}}.svg" class="img-fluid" alt="">
#else
<img style="border-radius: 0" src="https://demo.rayanscript.ir/-/vendor/cryptocurrency-icons/32/color/noimage.png" class="img-fluid" alt="">
#endif
</div>
<div class="user-info">
<span class="tb-lead english" style="font-weight: bolder">{{$value['name']}}</span>
<span class="english">{{$value['coin']}}</span>
</div>
</div>
</a>
</div>
<div class="nk-tb-col tb-col-mb">
<div class="btn-group" aria-label="Basic example">
<button type="button" class="btn btn-sm btn-dim btn-light" wire:click="getBalance('{{$value['coin']}}')">
<div wire:loading wire:target="getBalance('{{$value['coin']}}')">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
</div>
<span class="w-120px" id="coin-{{$value['coin']}}">get balance</span>
</button>
<button type="button" class="btn btn-sm btn-dim btn-primary">add coin</button>
</div>
</div>
</div>
#endforeach
</div>
</div>
</div>
</div>
</div>
But this error is given. Is my search method correct?
Array to string conversion

Failed to load resource: the server responded with a status of 500 (Internal Server Error) dynamic api

downloaded latest(3.0) boilerplate with zero.
Followed up the task creator application implementation on codeproject.com
I have added simple entity (Clients) instead of tasks.
The displaying of tasks work fine. However, when I try to add a new client the it seems that the dynamic api is not available and I get the following error:
ClientsController:
`[AbpMvcAuthorize]
public class ClientsController : MyAppControllerBase
{
private readonly IClientAppService _clientService;
public ClientsController(IClientAppService clientService)
{
_clientService = clientService;
}
public async Task<ViewResult> Index(GetAllClientsInput input)
{
var output = await _clientService.GetAll(input);
var model = new Web.Models.Clients.IndexViewModel(output.Items);
return View("Index", model);
}
public async Task Create(CreateClientInput input)
{
await _clientService.Create(input);
}
public async Task Delete(CreateClientInput input)
{
await _clientService.Create(input);
}
}`
Index.js:
(function() {
$(function() {
var _clientService = abp.services.app.client;
var _$modal = $('#ClientCreateModal');
var _$form = _$modal.find('form');
_$form.validate();
_$form.find('button[type="submit"]').click(function (e) {
e.preventDefault();
if (!_$form.valid()) {
return;
}
var client = _$form.serializeFormToObject(); //serializeFormToObject is defined in main.js
abp.ui.setBusy(_$modal);
_clientService.create(client).done(function () {
_$modal.modal('hide');
location.reload(true); //reload page to see new user!
}).always(function () {
abp.ui.clearBusy(_$modal);
});
});
_$modal.on('shown.bs.modal', function () {
_$modal.find('input:not([type=hidden]):first').focus();
});
});
})();
Index.cshtml
#section scripts
{
<environment names="Development">
<script src="~/js/views/clients/Index.js" asp-append-version="true"></script>
</environment>
<environment names="Staging,Production">
<script src="~/js/views/clients/Index.min.js" asp-append-version="true"></script>
</environment>
}
<div class="row clearfix">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="card">
<div class="header">
<h2>
#L("Clients")
</h2>
<ul class="header-dropdown m-r--5">
<li class="dropdown">
<a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<i class="material-icons">more_vert</i>
</a>
<ul class="dropdown-menu pull-right">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
</ul>
</li>
</ul>
</div>
<div class="body table-responsive">
<table class="table">
<thead>
<tr>
<th>#L("UserName")</th>
<th>#L("FullName")</th>
<th>#L("EmailAddress")</th>
<th>#L("IsActive")</th>
</tr>
</thead>
<tbody>
#foreach (var user in Model.Clients)
{
<tr>
<td>#user.FirstName</td>
<td>#user.LastName</td>
<td>#user.Email</td>
<td>#user.Mobile</td>
</tr>
}
</tbody>
</table>
<button type="button" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-right" data-toggle="modal" data-target="#ClientCreateModal">
<i class="material-icons">add</i>
</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="ClientCreateModal" tabindex="-1" role="dialog" aria-labelledby="ClientCreateModalLabel" data-backdrop="static">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form name="userCreateForm" role="form" novalidate class="form-validation">
<div class="modal-header">
<h4 class="modal-title">
<span>#L("CreateNewClient")</span>
</h4>
</div>
<div class="modal-body">
<div class="form-group form-float">
<div class="form-line">
<input class="form-control" type="text" name="FirstName" required maxlength="#AbpUserBase.MaxUserNameLength" minlength="2">
<label class="form-label">#L("FirstName")</label>
</div>
</div>
<div class="form-group form-float">
<div class="form-line">
<input type="text" name="LastName" class="form-control" required maxlength="#AbpUserBase.MaxNameLength">
<label class="form-label">#L("LastName")</label>
</div>
</div>
<div class="form-group form-float">
<div class="form-line">
<input type="text" name="Mobile" class="form-control" required maxlength="#AbpUserBase.MaxSurnameLength">
<label class="form-label">#L("Mobile")</label>
</div>
</div>
<div class="form-group form-float">
<div class="form-line">
<input type="email" name="Email" class="form-control" required maxlength="#AbpUserBase.MaxEmailAddressLength">
<label class="form-label">#L("Email")</label>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default waves-effect" data-dismiss="modal">#L("Cancel")</button>
<button type="submit" class="btn btn-primary waves-effect">#L("Save")</button>
</div>
</form>
</div>
</div>
</div>
client service :
[AbpAuthorize(PermissionNames.Pages_Tenants)]
public class ClientAppService : ApplicationService, IClientAppService
{
private readonly IRepository<Client> _clientRepository;
public ClientAppService(IRepository<Client> clientRepository)
{
_clientRepository = clientRepository;
}
public async Task<ListResultDto<ClientListDto>> GetAll(GetAllClientsInput input)
{
var clients = await _clientRepository
.GetAll().ToListAsync<Client>();
return new ListResultDto<ClientListDto>(
ObjectMapper.Map<List<ClientListDto>>(clients));
}
public async Task Create(CreateClientInput input)
{
var task = ObjectMapper.Map<Client>(input);
await _clientRepository.InsertAsync(task);
}
}
the server does not get hit at all on the create action.
any idea what I am missing?
I think there's a misunderstanding with IMustHaveTenant interface. When you derive an entity from IMustHaveTenant you cannot use that entity in host environment. The host has no tenant id. As far as i understand clients are belonging to tenants. So what you have to do is, remove the Clients page from host menu. Whenever you want to see clients of tenants, just use impersonation.
To show/hide specific menu items you can use requiredPermissionName. A permission can be configured to use just for tenants/host/both. So create a new permission which is configured to be used for tenants. Set that permission while you create new MenuItemDefinition for clients page. That's it!
Read => https://aspnetboilerplate.com/Pages/Documents/Navigation?searchKey=navigation#registering-navigation-provider

how to turn this spring boot thyme-leaf code into Ajax

I Have a comment and post system and I want To turn it into ajax without using thymeleaf fragmentation. How to do it i cannot figure out I do not want to refresh the page each time i make a post or comment .
Controller :
#Controller
public class DashboardController {
private Post post;
private User user;
#Autowired
private PostRepository postRepository;
#Autowired
private UserRepository userRepository;
#Autowired
CommentRepository commentRepository;
#RequestMapping(value = "/dashboard", method = RequestMethod.GET)
public String returnPosts(Model model) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String currentPrincipalName = authentication.getName(); //holding login user details
model.addAttribute("firstName", userRepository.findByEmail(currentPrincipalName).getFirstName());
model.addAttribute("newPost", new Post());
model.addAttribute("newComment", new Comment());
model.addAttribute("posts", postRepository.findAllByOrderByDateDesc());
model.addAttribute("comments", commentRepository.findAll());
return "main";
}
#RequestMapping(value = "/dashboard/posts", method = RequestMethod.POST)
public String addPost(Model model, #ModelAttribute Post post, #ModelAttribute User user) {
model.addAttribute("newPost", post);
creatPost(post);
System.out.println(post.getId());
return "redirect:/dashboard";
}
#RequestMapping(value = "/dashboard/comments", method = RequestMethod.POST)
public String addComment( Model model, #ModelAttribute Comment comment,
#ModelAttribute User user) {
model.addAttribute("newComment", comment);
// model.addAttribute("posts", post);
creatComment(comment.getPostId(), comment);
System.out.println(comment.toString());
//System.out.println(post.getId());
// System.out.println(comment.getPostId());
return "redirect:/dashboard";
}
private Comment creatComment(String id, Comment comment) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String currentPrincipalName = authentication.getName();
comment.setDate(new Date());
comment.setAuthor(userRepository.findByEmail(currentPrincipalName).getFirstName()
+ " " + userRepository.findByEmail(currentPrincipalName).getLastName());
comment.setPostId(id);
return commentRepository.save(comment);
}
private Post creatPost(Post post) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String currentPrincipalName = authentication.getName(); //holding login user details
post.setAuthor(userRepository.findByEmail(currentPrincipalName).getFirstName()
+ " " + userRepository.findByEmail(currentPrincipalName).getLastName());
post.setDate(new Date());
return postRepository.save(post);
}
}
Thymeleaf forms :
<div id="content" class="yellow col-xs-12">
<form class="col-xs-12" role="form" action="/dashboard/posts"
th:action="#{/dashboard/posts}" th:object="${newPost}" method="post">
<div class="form-group col-xs-12">
<textarea class="form col-xs-6" rows="2" id="full" placeholder="share anything....."
th:field="*{content}" style="font-size: 20px;" required="required"></textarea>
<div class="menu1 col-xs-12">
<hr/>
<ul class="text-center col-xs-12">
<a href="#">
<li>
<button type="submit" class="sendpost btn btn-success">Send</button>
</li>
<li class="xs-12 "><i class="fa fa-flash fa-lg"></i>Tasks</li>
<li class="xs-12"><i class="fa fa-paperclip fa-lg"></i>files</li>
<li class="xs-12"><i class="fa fa-calendar fa-lg"></i> calendar</li>
<li class="xs-12"><i class="fa fa-search fa-lg"></i>stying</li>
</a>
</ul>
</div>
</div>
</form>
<div>
<div th:each="post : ${posts}" style="border:2px solid #CCCCCC ; margin-bottom: 50px" id="post-div"
class="post-group col-xs-12">
<div class="imag col-xs-2">
<!--<input type="hidden" th:field="*{post.id}" disabled="disabled"/>-->
<img style="width: 50px;" src="images/1.png" class="img-circle img-responsive" alt=""/>
</div>
<div class=" col-xs-10">
<h4 style="line-height: .4;"><p class="name" th:text="*{post.author}">
</p>
<small style="color: #337ab7" th:text="*{post.date}"></small>
</h4>
<br/>
<p style="font-size: 20px" id="post-p" class="desc" th:text="*{post.content}"></p><br/>
<div class="footer ignore-zoom">
<a class="comment" onclick="showDiv1()"><i class="aa fa fa-comment"></i>
<span class="lin">0</span></a>
<a onclick="showDiv2()" href="#">
<i id="like" class="aa fa fa-heart active"></i>
<span style="display:none;" id="like-1" class="lin">1</span></a>
<a class="aa dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false"><i
class="fa fa-pencil"></i> </a>
</div>
<div th:each="comment : ${comments}" id="my-comment">
<div th:if="${post.id == comment.postId}">
<hr/>
<br/>
<img class="img-circle img-responsive" src="images/1.png"
style="margin-right:5%; width: 50px; display: inline-flex; color:#080602;"/>
<div style="line-height:.8">
<label th:text="*{comment.author}"> </label><br/>
<small th:text="*{comment.date}" style=" color: #337ab7 ; margin-left:16%;">time of
comment
</small>
</div>
<br/>
<p style="font-size: 16px;" id="-comment" th:text="*{comment.comment}"></p>
<div class="footer footer1 ignore-zoom">
<a onclick="showDiv4()" href="#">
<i id="like1" class="aa fa fa-heart active"></i>
<span style="display:none;" id="like-2" class="lin">1</span></a>
<a class="aa dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false"><i
class="fa fa-pencil"></i> </a>
</div>
</div>
</div>
<form role="form" action="/dashboard/comments"
th:action="#{/dashboard/comments}" th:object="${newComment}" method="post">
<input type="hidden" name="postId" th:value="${post.id}"/>
<div id="comment-div" class="form-group col-xs-12">
<textarea th:field="*{comment}" class="form col-xs-6" rows="2" id="full2"
placeholder="Your Comment....." required="required"></textarea>
<div class="menu1 col-xs-12">
<hr/>
<ul class="text-center col-xs-12">
<a href="#">
<li onclick="showDiv()">
<button type="submit" class="btn btn-info">Send</button>
</li>
<li class="xs-12 "><i class="fa fa-flash fa-lg"></i></li>
<li class="xs-12"><i class="fa fa-paperclip fa-lg"></i></li>
<li class="xs-12"><i class="fa fa-calendar fa-lg"></i></li>
<li class="xs-12"><i class="fa fa-search fa-lg"></i></li>
</a>
</ul>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
You can have a look at the tutorial http://www.thymeleaf.org/doc/tutorials/2.1/thymeleafspring.html#ajax-fragments
And the content is as below:
Ajax fragments
WebFlow allows the specification of fragments to be rendered via AJAX with tags, like this:
<view-state id="detail" view="bookingDetail">
<transition on="updateData">
<render fragments="hoteldata"/>
</transition>
</view-state>
These fragments (hoteldata, in this case) can be a comma-separated list of fragments specified at the markup with th:fragment :
<div id="data" th:fragment="hoteldata">
This is a content to be changed
</div>
Always remember that the specified fragments must have an id attribute, so that the Spring JavaScript libraries running on the browser are capable of substituting the markup.
tags can also be specified using DOM selectors:
<view-state id="detail" view="bookingDetail">
<transition on="updateData">
<render fragments="[//div[#id='data']]"/>
</transition>
</view-state>
...and this will mean no th:fragment is needed:
<div id="data">
This is a content to be changed
</div>
As for the code that triggers the updateData transition, it looks like:
<script type="text/javascript" th:src="#{/resources/dojo/dojo.js}"></script>
<script type="text/javascript" th:src="#{/resources/spring/Spring.js}"></script>
<script type="text/javascript" th:src="#{/resources/spring/Spring-Dojo.js}"></script>
...
<form id="triggerform" method="post" action="">
<input type="submit" id="doUpdate" name="_eventId_updateData" value="Update now!" />
</form>
<script type="text/javascript">
Spring.addDecoration(
new Spring.AjaxEventDecoration({formId:'triggerform',elementId:'doUpdate',event:'onclick'}));
</script>

Added Fine Uploader and can't upload files

Can't seem to get this to work. I have literally tried everything. Can anyone help me please. I have been trying to figure this out for some time now and about to give up with this plugin. The errors I am getting are not really telling me anything at all. The uploads folder has the proper permissions.
I basically created a new c# Web Application and added the following: http://docs.fineuploader.com/quickstart/02-setting_options.html
PLEASE HELP
<!-- Fine Uploader -->
<script src="../Scripts/fineuploader/fine-uploader.min.js" type="text/javascript"></script>
<script type="text/template" id="qq-template">
<div class="qq-uploader-selector qq-uploader" qq-drop-area-text="Drop files here">
<div class="qq-total-progress-bar-container-selector qq-total-progress-bar-container">
<div role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" class="qq-total-progress-bar-selector qq-progress-bar qq-total-progress-bar"></div>
</div>
<div class="qq-upload-drop-area-selector qq-upload-drop-area" qq-hide-dropzone>
<span class="qq-upload-drop-area-text-selector"></span>
</div>
<div class="qq-upload-button-selector qq-upload-button">
<div>Upload a file</div>
</div>
<span class="qq-drop-processing-selector qq-drop-processing">
<span>Processing dropped files...</span>
<span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span>
</span>
<ul class="qq-upload-list-selector qq-upload-list" aria-live="polite" aria-relevant="additions removals">
<li>
<div class="qq-progress-bar-container-selector">
<div role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" class="qq-progress-bar-selector qq-progress-bar"></div>
</div>
<span class="qq-upload-spinner-selector qq-upload-spinner"></span>
<img class="qq-thumbnail-selector" qq-max-size="100" qq-server-scale>
<span class="qq-upload-file-selector qq-upload-file"></span>
<span class="qq-edit-filename-icon-selector qq-edit-filename-icon" aria-label="Edit filename"></span>
<input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text">
<span class="qq-upload-size-selector qq-upload-size"></span>
<button class="qq-btn qq-upload-cancel-selector qq-upload-cancel">Cancel</button>
<button class="qq-btn qq-upload-retry-selector qq-upload-retry">Retry</button>
<button class="qq-btn qq-upload-delete-selector qq-upload-delete">Delete</button>
<span role="status" class="qq-upload-status-text-selector qq-upload-status-text"></span>
</li>
</ul>
<dialog class="qq-alert-dialog-selector">
<div class="qq-dialog-message-selector"></div>
<div class="qq-dialog-buttons">
<button class="qq-cancel-button-selector">Close</button>
</div>
</dialog>
<dialog class="qq-confirm-dialog-selector">
<div class="qq-dialog-message-selector"></div>
<div class="qq-dialog-buttons">
<button class="qq-cancel-button-selector">No</button>
<button class="qq-ok-button-selector">Yes</button>
</div>
</dialog>
<dialog class="qq-prompt-dialog-selector">
<div class="qq-dialog-message-selector"></div>
<input type="text">
<div class="qq-dialog-buttons">
<button class="qq-cancel-button-selector">Cancel</button>
<button class="qq-ok-button-selector">Ok</button>
</div>
</dialog>
</div>
</script>
<script>
var uploader = new qq.FineUploader(
{
debug: true,
element: document.getElementById('fine-uploader'),
request: {
endpoint: '/Uploads'
},
deleteFile: {
enabled: true,
endpoint: '/Uploads'
},
retry: {
enableAuto: true
},
callbacks: {
onError: function (id, name, errorReason, xhrOrXdr) {
alert(qq.format("Error on file number {} - {}. Reason: {}", id, name, errorReason));
}
}
});
</script>
Figured it out finally, I added a HttpHandler and changed the request endpoint to point to the handler.
public class ImageUploader : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
try
{
Stream str = context.Request.InputStream;
BinaryReader br = new BinaryReader(str);
Byte[] FileContents = { };
string UploadFile = string.Empty;
bool IE = false;
if (context.Request.Browser.Browser == "IE")
{
IE = true;
HttpFileCollection MyFiles = HttpContext.Current.Request.Files;
HttpPostedFile PostedFile = MyFiles[0];
if (!PostedFile.FileName.Equals(""))
{
String fn = Path.GetFileName(PostedFile.FileName);
br = new BinaryReader(PostedFile.InputStream);
UploadFile = fn;
}
}
if (IE)
{
HttpContext.Current.Request.Files[0].SaveAs(HttpContext.Current.Server.MapPath("~/uploads/" + UploadFile));
}
else
{
HttpContext.Current.Request.Files[0].SaveAs(HttpContext.Current.Server.MapPath("~/uploads/" + HttpContext.Current.Request.Files[0].FileName));
}
HttpContext.Current.Response.Write("{\"success\":true}");
}
catch (Exception Ex)
{
HttpContext.Current.Response.Write("{\"error\":}" + Ex.Message);
}
}
public bool IsReusable
{
get
{
return false;
}
}
}

Resources