This question already has answers here:
Is Boostrap compatible with Struts 2?
(2 answers)
Closed 5 years ago.
I am beginner of struts2 and bootstarp. I can not use bootstrap with my struts2 form . I am using the following Jar:
commons-fileupload-1.2.2.jar
common-io-2.0.1.jar
commons-lang3-3.1.jar
commons-logging-1.1.1.jar
commons-logging-api-1.1.jar
freemaker-2.3.19.jar
javaassist-3.11.0.GA.jar
javax.servlet-api-3.0.1.jar
mysql-connector.jar
ognl-3.0.6.jar
struct2-core-2.3.14.2.jar
xwork-core-2.3.14.2.jar
asm-3.3.1.jar
asm-commons-3.3.jar
asm-tree-3.3.jar
my jsp page is below:
<%# taglib uri="/struts-tags" prefix="s" %>
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link href="./css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
</head>
<body>
<s:form action="loginprocess" cssClass="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
<s:textfield name="username" ></s:textfield>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="pwd">Password:</label>
<div class="col-sm-10">
<s:password name="userpass" ></s:password>
</div>
</div>
<s:submit value="login"></s:submit>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
</div>
</div>
</s:form>
Not registered yet ,Please Sign Up
Sign Up
</body>
</html>
but it gives a horrible output where all elements are broken. Output is below:
output of my project
which extra jar files I need to add to my project? or what more things is require to create form using struts2 and bootstrap? Please help.
Add theme="simple" to all struts elements.
Like :-
<s:form action="loginprocess" cssClass="form-horizontal" theme="simple">
Related
I have an assignment that requires us to use a shared Layout, tag helpers, etc. The Razor code works fine on every page except for the confirmaccount page
Here is a page it is working fine on:
#addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
#model bit285_assignment1_naps.Models.User;
#{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="/naps.css" />
<title>Login Page</title>
</head>
<body>
<h1>Login</h1>
<fieldset>
<form>
<div>
<label>Username</label>
<input value="ian#home.com" />
<span>* required</span>
</div>
<div>
<label>Password</label>
<input type="password" value="bl-blue-Bansenauer" />
<span>* required</span>
</div>
<div>
<input type="button" value="Login" />
<input type="button" value="Reset" />
</div>
</form>
</fieldset>
</body>
</html>
And here is the problematic page:
#addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
#model bit285_assignment1_naps.Models.User;
#{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="/naps.css" />
<title>Account Confirmation</title>
</head>
<body>
<h1>New Account Created</h1>
<fieldset>
<form>
<div>
<label>FirstName</label>
<span>Brian</span>
</div>
<div>
<label>Last Name</label>
<span>Bansenauer</span>
</div>
<div>
<label>Program</label>
<span>Web App Dev</span>
</div>
<div>
<label>Username</label>
<span>ian#home.com</span>
</div>
<div>
<label>Password</label>
<span>bl-blue-Bansenauer</span>
</div>
<div>
<input type="button" onclick="location.href='/login.html';" value="Go to Login" />
<input type="button" value="Reset" />
</div>
</form>
</fieldset>
</body>
</html>
At the very least, on the latter, the VS is not recognizing it and the text is completely white.
The first file is login.cshtml, the second is confirmaccount.cshtml
I have no idea why the confirmaccount one is not working, the code #model/layout works fine for 5 other pages. Also, most of this code is premade by my instructor and not my original work.
I have been trying to implement DhtmlxScheduler Standard Edition v.3.5 in to my mvc3 project.
Following the tutorial at http://www.dhtmlx.com/blog/?p=639
The tutorial is in mvc2 I believe and I am having a bit of trouble following it.
Here is my view page;
#*#Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>";*#
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Index</title>
<script src="#Url.Content("~/Scripts/dhtmlxscheduler.js")" type="text/javascript"></script>
<link href="#Url.Content("~/Scripts/dhtmlxscheduler.css")" rel="stylesheet" type="text/css" />
<style type="text/css">
html, body
{
height:100%;
padding:0px;
margin:0px;
}
</style>
<script type="text/javascript">
function init() {
scheduler.init("scheduler_here", new Date(2010, 6, 1), "month");
}
</script>
</head>
<body onload="init()">
<div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'>
<div class="dhx_cal_navline">
<div class="dhx_cal_prev_button"> </div>
<div class="dhx_cal_next_button"> </div>
<div class="dhx_cal_today_button"></div>
<div class="dhx_cal_date"></div>
<div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div>
<div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
<div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
</div>
<div class="dhx_cal_header">
</div>
<div class="dhx_cal_data">
</div>
</div>
</body>
</html>
When I run this page with out the style-sheet it loads the calender but it is all over the place, so I add the CSS and them I get nothing??
What exactly goes wrong? This code will work in mvc3, except maybe that you should add #{Layout = null;} at the top of the page. Scheduler should occupy the whole size of its container, which is div#scheduler_here.
If you want scheduler to take only the part of the page, you can set sizes of "scheduler_here", eg <div id="scheduler_here" class="dhx_cal_container" style='width:960px;margin:0 auto;height:100%;'>
Hope it helps.
Please help me on this. I am new to CSS and jQuery Mobile and I got this issue.
The checkboxes in my page do not display the box; only the label. When I click the label, a square appears on the left.
Now, the issue only happens if I download the CSS file to my local file and refer that. If I refer the CSS file from the server directly, the box appears before the text and works normally. Below are the sample source:
Source which has error:
<!DOCTYPE HTML>
<html>
<head>
<title>Mobile App Login</title>
<meta name=viewport content="user-scalable=no,width=device-width">
<link rel="stylesheet" href="../jQuery/jquery.mobile.css">
<script src="../jQuery/jquery.js"></script>
<script src="../jQuery/jquery.mobile.js"></script>
</head>
<body>
<div data-role=page id=home>
<div data-role=header>
<h1>Login Screen</h1>
</div>
<div data-role=content>
<label>
<input type="checkbox" name="checkbox-0" />
I agree
</label>
<input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" />
<label for="checkbox-1">I agree</label>
</div>
</div>
</body>
</html>
Source which does not have error:
<!DOCTYPE HTML>
<html>
<head>
<title>Mobile App Login</title>
<meta name=viewport content="user-scalable=no,width=device-width" />
<link rel="stylesheet" href="http://jquerymobile.com/test/css/themes/default/jquery.mobile.css" />
<script src="../jQuery/jquery.js"></script>
<script src="../jQuery/jquery.mobile.js"></script>
</head>
<body>
<div data-role=page id=home>
<div data-role=header>
<h1>Login Screen</h1>
</div>
<div data-role=content>
<label>
<input type="checkbox" name="checkbox-0" />
I agree
</label>
<input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" />
<label for="checkbox-1">I agree</label>
</div>
</div>
</body>
</html>
Everything else works fine; it is just the display of the box that causes me the problem. I took the latest files for the CSS and JS files and checked.
Without the box, the user may think it is just a label
Since I am new, I am unable to give an image, I'm sorry...
Thanks all.
Adding checkbox inside fieldset for me solved the same problem.
<fieldset data-role="controlgroup">
<input type="checkbox" name="checkbox-2" id="checkbox-2" class="custom" />
<label for="checkbox-2">I agree</label>
</fieldset>
I use a master page for my site and for some reason, I can no longer view the master page in design view. All that appears is a blank page with a blinking cursor. I've been at it for over 2 hours and can't figure it out. Yet when I run it, everything looks and behaves great. What am I missing?
Here is the Site.Master code:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="WebApplication2.SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title></title>
<%--Here is where you reference your style sheets and JQuery library. The link href takes the
relative path and publishes fine for the directory. With <script> and <style> tags, copies
like the JQuery reference, you will need to use the '<%# Page.ResolveClientUrl() %>' to get
the same relative path behavior at publishing time. Typically you would define a code block
and choose '<%=' however page headers don't play nice with code blocks. '<%#' defines as a
databinding expression and then when you add Page.Header.Databind() to your code behind for
the master page, The DataBind method evaluates all the databinding expression(s) in your
header at load time--%>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<link href="~/Styles/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%# Page.ResolveClientUrl("~/Scripts/jquery-1.4.1.min.js") %>"></script>
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<%--The ScriptManager is a what is used by the Microsoft controls to provide AJAX functionality.
It needs to exist for the the AJAX libraries to be referenced and placing it right below the
Master's page Form tag is the best place--%>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div class="page">
<div class="header">
<div class="title">
<h1>
SalesPro Technologies Online
</h1>
</div>
<div class="loginDisplay">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<AnonymousTemplate>
[ Log In ]
</AnonymousTemplate>
<LoggedInTemplate>
Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
[ <asp:LoginStatus ID="HeadLoginStatus" runat="server"
LogoutAction="RedirectToLoginPage" LogoutText="Log Out"
LogoutPageUrl="~/Account/Login.aspx"/> ]
</LoggedInTemplate>
</asp:LoginView>
</div>
<div id="divMenu" class="clear hideSkiplink">
<%-- The following code is for a traditional menu bar to appear:
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false"
Width="40%" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
</Items>
</asp:Menu> --%>
<asp:LinkButton CssClass="LinkCss floatleft" ID="linkHome" runat="server"
PostBackUrl="~/Default.aspx">Home</asp:LinkButton>
<asp:LinkButton CssClass="LinkCss floatright" ID="linkAbout" runat="server"
PostBackUrl="~/About.aspx">About</asp:LinkButton>
<asp:LinkButton CssClass="LinkCss floatright" ID="linkOptions" runat="server">Options</asp:LinkButton>
<asp:LinkButton CssClass="LinkCss floatright" ID="linkReports" runat="server"
PostBackUrl="~/reports.aspx">Reports</asp:LinkButton>
</div>
</div>
<div class="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
</body>
</html>
I think your comments with ASP tags in it are confusing Visual Studio. Try removing <%= <%# %> from within your comments and see if that helps. If this is your problem you may need to add spaces within the tags so they don't confuse VS. ie. < % = You should still be able to understand your comments.
Opera is displaying my new site as XML and I can't for the life of me figure out why.
Here's what firebug has to say
Server ASP.NET Development Server/10.0.0.0
Date Mon, 08 Nov 2010 22:58:32 GMT
X-AspNet-Version 4.0.30319
X-AspNetMvc-Version 2.0
Content-Encoding gzip
Cache-Control private
Content-Type text/html; charset=utf-8
Content-Length 1835
Connection Close
Here's what W3C has to say
Line 3, column 6: application/xhtml+xml is not an appropriate Content-Type for a document whose root element is not in a namespace.
<html>
Line 3, column 6: Unnamespaced element html not allowed in this context. (Suppressing further errors from this subtree.)
<html>
Here's the markup
<!DOCTYPE html>
<html>
<head>
<title>What's happening around you right now! - My App</title>
<meta content="no" http-equiv="imagetoolbar" />
<link rel="search" type="application/opensearchdescription+xml" title="My App" href="/assets/xml/opensearch.xml" />
<link rel="stylesheet" type="text/css" href="/MYREALLYCOOLAPP/Extras/siteMaster.Css/1" />
</head>
<body>
<div class="page">
<div id="header">
<div id="title">
<div id="urban-now-logo">
<span>My App</span>
</div>
</div>
<div id="logindisplay">
<span id="logindisplaywrapper">log in | <a href="/MYREALLYCOOLAPP/modalwindow/selectregion"
title="Change Region" class="RegionWindow">Calgary</a> | about | faq
<span style="padding-left: 20px;"></span>
<form action="/MYREALLYCOOLAPP/search" id="searchForm" method="get">
<input id="search-text" name="q" tabindex="1" type="text" maxlength="80" size="28" placeholder="search..." />
</form>
</span>
</div>
<div id="menucontainer">
<div class="floatleft">
<ul class="menu">
<li><a class="youarehere" href="/MYREALLYCOOLAPP/">Now</a></li>
<li>Coming</li>
<li>Hot</li>
<li>Tags</li>
<li>Users</li>
</ul>
</div>
<div class="floatright">
<ul class="menu">
<li>Add Event</li>
</ul>
</div>
</div>
</div>
<div class="clear">
</div>
<div id="main">
<h2>What's Happening Within The Next 24 Hours!</h2>
<hr />
<div id="innermain">
<div class="twocolumn-left">
<div id='bingMap' class="largeMap">
<noscript>
<img src="http://developer.multimap.com/API/map/1.2/OA10091719904371779?zoomFactor=11&width=550&height=400&lat_1=51.18468&lon_1=-114.497999&lat_2=51.169858&lon_2=-114.32549&lat_3=51.083277&lon_3=-114.203964&lat_4=51.063097&lon_4=-114.092031&lat_5=50.939664&lon_5=-113.973568" />
</noscript>
</div>
</div>
<div class="twocolumn-right">
</div>
</div>
<div id="footer">
<ul id="footernavigation">
<li>© 2010 - My App - All Rights Reserved</li>
<li><span class="colorgreen increasesize-140">■</span> about | <span class="colorgreen increasesize-140">
■</span> faq | <span class="colorgreen increasesize-140">■</span> <a href="/MYREALLYCOOLAPP/about/advertise">
advertise</a> | <span class="colorgreen increasesize-140">■</span> legal</li>
</ul>
</div>
</div>
</div>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"></script>
<script type="text/javascript" src="/MYREALLYCOOLAPP/Extras/MYREALLYCOOLAPP.js/1"></script>
<script type="text/javascript">
var zoomLevel = 10
var json_object = [{ "lat": 51.063097, "lon": -114.092031, "title": "Jubilee Auditorium", "desc": "Some great concerts go down here"}];
</script>
<script type="text/javascript" src="/MYREALLYCOOLAPP/Extras/bingmaps.js/1"></script>
</body>
</html>
Basically, when I launch the website in Opera, the top says
This document had no style information.
and then all of my markup is displayed (like xml).
It looks like your server is sending the file as text/html to Firefox, but application/xhtml+xml to Opera.
Opera (10.63) has a firebug-like interface you can check this with. Right click on a page to bring up the context menu, select "Inspect Element". Select the "Network" tab and expand the relevant request line. Then open either "Headers" or "Raw" and it will show you the content-type used to send the page to Opera.
To allow Opera to process the page correctly as application/xhtml+xml, add
xmlns="http://www.w3.org/1999/xhtml"
as an attribute to the html element as LukeH says.
Doesn't your DOCTYPE need to specify the appropriate DTD etc? For example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
And/or do you need to specify a namespace for your <html> element? For example:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">