JS Calendar + JSF - jsf

sorry about input mistakes, english its not my mother lang.
I have this code written on normal html that i managed to transform into xhtml file, i want to send the value shown on <input id="f_date"> to <h:inputText>:
<script src="../js/jscal2.js" type="text/javascript" xml:space="preserve"></script>
<script src="../js/lang/en.js" type="text/javascript" xml:space="preserve"></script>
<link rel="stylesheet" type="text/css" href="../css/jscal2.css" />
<link rel="stylesheet" type="text/css" href="../css/border-radius.css" />
<link rel="stylesheet" type="text/css" href="../css/steel/steel.css" />
<h:form id="form1">
<table>
<tr>
<td colspan="4" id="cont"></td>
</tr>
<tr>
<td>
<input style="text-align: center" name="date" id="f_date"
size="14" />
<h:inputText id="f_date" value="#{solicitud.fechaI}" maxlength="10" size="10" valueChangeListener="#{solicitud.fechaIText}">
<a4j:ajax event="keyup" render="fechaI, fIni" status="statusFI"/>
</h:inputText>
</td>
<td>
<input style="text-align: center" name="hour" id="f_hour" size="2" />
</td>
<td>
:
</td>
<td>
<input style="text-align: center" name="minute" id="f_minute"
size="2" />
</td>
</tr>
</table>
</h:form><script type="text/javascript" xml:space="preserve">//<![CDATA[
function updateFields(cal) {
var date = cal.selection.get();
if (date) {
date = Calendar.intToDate(date);
document.getElementById("f_date").value = Calendar.printDate(date, "%Y-%m-%d");
}
document.getElementById("f_hour").value = cal.getHours();
document.getElementById("f_minute").value = cal.getMinutes();
};
Calendar.setup({
cont : "cont",
showTime : 12,
onSelect : updateFields,
onTimeChange : updateFields
});
//]]></script>
Thanks in advance, best regards

You should reuse input element from <h:inputText> when setting up JS calendar. Use inputField argument to pass id of input generated by JSF. It could be form1:f_date but check html source to make sure.
EDIT:
prefix id with "form1:" in updateFields"
document.getElementById("form1:f_date")
and get rid of
<input style="text-align: center" name="date" id="f_date"
size="14" />

Related

Bad color in table. Bootstrap 5.2.3

I have no practice as a bootstrap user.
I have a table. when i set dark mode in browser then the color of text is wrong (black on black background).
What am I doing wrong?
(fg-color is only bad in table when class="table" added)
<!doctype html>
<html lang="pl">
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="/static/admin/css/base.css">
<link rel="stylesheet" type="text/css" href="/static/admin/css/nav_sidebar.css">
<link rel="stylesheet" type="text/css" href="/static/admin/css/dashboard.css">
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" type="text/css" href="/static/admin/css/responsive.css">
</head>
<body>
<table class="table table-responsive table-bordered">
<thead>
<tr>
<th class="text-center" scope="col">Name</th>
<th class="text-center" scope="col">Price</th>
<th class="text-center" scope="col">Qnt</th>
</tr>
</thead>
<tbody>
<tr>
<td>product 1</td>
<td class="text-end">12,48</td>
<td class="float-right"><input class="form-control float-right" type="number" min="1" max="999"></td>
</tr>
<tr>
<td>product 2</td>
<td class="text-end">12,48</td>
<td class="float-right"><input class="form-control float-right" type="number" min="1" max="999"></td>
</tr>
<tr>
<td>product 3</td>
<td class="text-end">12,48</td>
<td class="float-right"><input class="form-control float-right" type="number" min="1" max="999"></td>
</tr>
</tbody>
</table>
</body>
</html>
I tried using a div container and some classes but it doesn't change anything.
For styling depending on browser based color mode/theme, you can use the prefers-color-scheme media query as it is used to detect whether the user has requested a light or dark theme based on operating system setting or user agent (browser in this case) settings.
You can set the color for the table using this query:
#media (prefers-color-scheme: dark) {
your-selector {
color: white;
}
}
Reference - MDN

XPATH Syntax - Katalon Studio

Hi,
I wanted to get the text from the webpage with Cucumber & Groovy in Katalon Studio. Please find the below Step Definition which has the xpath and below is the html code.
I wanted to read the below two lines from the page which can be referred in the html code also below. The number 596 varies each time i.e., dynamic.
Create Inquiry Tracking # 596
The inquiry for system tracking # 596 has been submitted successfully
Step Definition
inquiryt1 = WebUI.getText(findTestObject(By.xpath("//td[#class='pageTitle'][1]")))
Full Page HTML :
<html lang="en">
<head>
<title>Govt Inquiry</title>
<link rel="stylesheet" type="text/css" href="?appId=gmpinquiry&flName=/uitmpl/en/css/uitmpl.css" />
<link rel="stylesheet" type="text/css" href="?appId=gmpinquiry&flName=/gmpinquiry/css/gmpinquiry.css" />
<script type="text/javascript" src="?appId=gmpinquiry&flName=/uitmpl/js/other_scripts.js"></script>
<script type="text/javascript" src="?appId=gmpinquiry&flName=/uitmpl/js/freezingHeader.js"></script>
<script type="text/javascript" src="?appId=gmpinquiry&flName=/uitmpl/js/sortTable.js"></script>
<noscript>
<style>
table.mQH {display:block;}
</style>
</noscript>
<style id="antiClickjack">body{display:none !important;}</style>
<script type="text/javascript">
if (self === top) {
var antiClickjack = document.getElementById("antiClickjack");
antiClickjack.parentNode.removeChild(antiClickjack);
} else {
top.location = self.location;
}
</script>
</head>
<body onload="uitmpl_qhPageInit()">
<!-- Skip To Main Content should be the next element immediately after body element -->
<div class="skipnav">Skip to Main Content </div>
<script type="text/javascript" src="?appId=gmpinquiry&flName=/uitmpl/js/menu_script.js"></script>
<script type="text/javascript" src="?appId=gmpinquiry&flName=/uitmpl/js/application_settings.js"></script>
<script type="text/javascript" src="?appId=gmpinquiry&flName=/uitmpl/js/global_settings.js"></script>
<script language="javascript">
application.data = {
td_1: "Home",
td_2: "Govt Inquiry",
td_3: "Create Inquiry",
td_4: "Reports/Search",
td_5: "My Preference",
url_1: "javascript:OnGMPPortalSubmit(document.frmMenuScr, '')",
url_2: "javascript:OnMenuSubmit (document.frmMenuScr, 'homepage')",
url_3: "javascript:OnMenuDispatch (document.frmMenuScr, 'setupinquiry','create')",
url_4: "javascript:OnMenuSubmit (document.frmMenuScr, 'inqsubmenu')",
url_5: "javascript:OnMenuSubmit (document.frmMenuScr, 'userpref')"
};
global.data = {
//td_1: "AT&T BusinessDirect",
td_1: "Write Us",
td_2: "Help <span class=\"offscrn\"> - Opens a PDF Document for Help</span>",
td_3: "Close",
//td_3_1: "General Help",
//td_3_2: "Application Tutorial",
//td_3_3: "<span id=\"shHd\">Show</span> Quick Help",
//url_1: "javascript:bizDirect()",
url_1: "javascript:OnMenuSubmit(document.frmMenuScr, 'compose')",
url_2: "javascript:uitmpl_popUpReg(document.frmMenuScr.action + '?appId=' + document.frmMenuScr.appId.value + '&flName=' + document.frmMenuScr.context.value + '/help/Inquiry_UG.pdf')",
url_3: "javascript:window.close();"
//url_3_1: "javascript:uitmpl_popUpReg(document.frmMenuScr.action + \\'?appId=\\' + document.frmMenuScr.appId.value + \\'&flName=\\' + document.frmMenuScr.context.value + \\'/help/Inquiry_UG.pdf\\')",
//url_3_2: "#",
//url_3_3: "javascript:uitmpl_qhPageToggle()"
};
</script>
<script type="text/javascript" src="?appId=gmpinquiry&flName=/gmpinquiry/js/script.js"></script>
<!--************ uitmplbegin: tBAN ************-->
<!--****** begin:background graphic ******-->
<table width="100%" cellspacing="0" border="0" class="tBAN">
<tr>
<td><img src="?appId=gmpinquiry&flName=/uitmpl/en/img/swoosh.gif" width="650" height="69" alt="" border="0" /></td>
</tr>
</table>
<!--****** end:background graphic ******-->
<!--****** begin:logo and company title ******-->
<div class="logoCompany">
<table width="100%" cellspacing="0" border="0" class="tBAN">
<tr>
<td class="logo"><img src="?appId=gmpinquiry&flName=/uitmpl/en/img/attbizdirect.gif" width="291" height="63" alt="AT&T | Business Direct" border="0" /></td>
<td><!-- stretchable cell --></td>
<!-- max characters for company title: 72 w/ breaks (24 per line) -->
<td class="company">ATT Gov Sol Dev<br/>rm0013
<!-- Begin Skip Top Navigation -->
<!-- <div class="skipnav">Skip to Main Content</div> -->
<!-- End Skip Top Navigation --></td>
</tr>
</table>
</div>
<!--****** end:logo and company title ******-->
<!--****** begin:application title ******-->
<table cellspacing="0" border="0" class="appTitle">
<tr>
<td>View and Analyze Govt. Bills: Govt Inquiry</td>
</tr>
</table>
<!--****** end:application title ******-->
<!--************ uitmplend: tBAN ************-->
<!--************ uitmplbegin: tNAV ************-->
<div id="glbl">
<script language="JavaScript1.3">
<!--
uitmpl_list("global");
//-->
</script>
<noscript>
<div class="globalAcc">
<table class="global_main" cellspacing="0" border="0">
<tr>
<td class="global_main_spacer"> </td>
<td>AT&T BusinessDirect</td><td class="pipe">|</td><td>Write Us</td><td class="pipe">|</td><td>Help</td>
</tr>
</table>
</div>
</noscript>
</div>
<div id="app">
<script language="JavaScript1.3">
<!--
uitmpl_list("application");
//-->
</script>
<noscript>
<div class="applicationAcc"><table class="application_main" cellspacing="0" border="0">
<tr>
<td>Home</td>
<td class="pipe">|</td>
<td>Create/Update Dispute</td>
<td class="pipe">|</td>
<td>Reports/Search</td>
<td class="pipe">|</td>
<td>My Preference</td>
<td class="pipe">|</td>
<td>User Management</td>
</tr>
</table>
</div>
</noscript>
</div>
<!--************ uitmplend: tNAV ************-->
<form name="frmMenuScr" action="/servlet/GMPGate" method="get">
<input type="hidden" name="appId" value="gmpinquiry">
<input type="hidden" name="nextScr" value="userpref">
<input type="hidden" name="methodToCall" value=""/>
<input type="hidden" name="context" value="/gmpinquiry"/>
</form>
<!--***** begin:grid *****-->
<table width="100%" cellspacing="0" border="0" class="wrap">
<tr>
<td width="100%" class="grid">
<!-- InstanceBeginEditable name="PageHeader" -->
<!--************ uitmplbegin: tPH ************-->
<!--****** begin:titles ******-->
<table cellspacing="0" border="0" class="tPH">
<!--****** begin:page title ******-->
<tr>
<td class="pageTitle">Create Inquiry Tracking # 599</td>
</tr>
<!--****** end:page title ******-->
</table>
<!--****** end:titles ******-->
<!--************ uitmplend: tPH ************-->
<!-- InstanceEndEditable -->
</td>
<td width="182" class="grid"><img src="?appId=gmpinquiry&flName=/uitmpl/en/img/pixel.gif" width="182" height="1" alt="" border="0" /></td>
</tr>
</table>
<!--***** end:grid *****-->
<!--***** begin:grid *****-->
<table width="100%" cellspacing="0" border="0" class="wrap">
<tr>
<td width="100%" class="grid">
<!--- BeginOptional name="TaskConfirmation" --->
<!-- InstanceBeginEditable name="TaskConfirmation" -->
<!--************ uitmplbegin: mTC ************-->
<table cellspacing="0" cellpadding="2" border="0" class="mTC">
<tr class="msgConfirm">
<td> <img src="?appId=gmpinquiry&flName=/uitmpl/en/img/confirmation.gif" width="29" height="29"
border="0" alt="Confirmation." /></td><td>The inquiry for system tracking # 599 has been submitted successfully. </td>
</tr>
</table>
REASON FOR FAILED WITH THE SOLUTION
2019-06-26 18:40:10.049 ERROR c.k.k.c.c.keyword.CucumberReporter
- ❌ it should displays create inquiry pages FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.testobject.ObjectRepository.findTestObject()
is applicable for argument types: (org.openqa.selenium.By$ByXPath) values: [By.xpath: //td[#class='pageTitle'][1]]
Possible solutions: findTestObject(java.lang.String), findTestObject(java.lang.String, java.util.Map) at CreateInquiry001.it_should_displays_create_inquiry_page2(CreateInquiry001.groovy:369)
at ✽.it should displays create inquiry pages(C:/Users/vdavuluri2/Katalon Studio/Govt Inquiry/Include/features/Create Inquiry-001.feature:55)
Katalon's findTestObject() method is used for selecting an object from the object repository. It doesn't work with By class.
You can try with something like the following: create an object with the given Xpath and then use WebUI.getText() on it:
TestObject testObject = new TestObject().addProperty("xpath", ConditionType.EQUALS, "//td[#class='pageTitle'][1]")
WebUI.getText(testObject)
The element with class pageTitle looks unique so why not user
//td[#class='pageTitle']

VBA Excel - Filling in webforms unable to click submit button

I am fairly new to coding and took on this project to create 1000 new accounts in an internal program we have at my work. I was able to get the macro to fill in the webform and proceed through 2 pages however at the third page I was unable to get it to click the submit button.
Code:
Sub Automate1()
Dim IE As Object
Dim doc As HTMLDocument
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://associate.heritagerep.com/signup/signup.asp?
SectionID=10&t=10030&guid=CB57C450-F8D2-4644-98CB-99C37DA43668"
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Set doc = IE.document
'First Screen'
doc.getElementsByName("sponsor")(0).Value = "kffrep"
doc.getElementById("Username").Value = "75871"
doc.getElementById("email").Value = "75871#kff.com"
doc.getElementById("zip").Value = "111111"
doc.getElementsByName("Submit")(0).Click
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
'Second Screen'
doc.getElementById("companyName").Value = "kff1"
doc.getElementById("OccupationTy_Select").Value = 34
doc.getElementById("fname").Value = "75871"
doc.getElementById("lname").Value = "kff1"
doc.getElementById("mstreet1").Value = "1 kff st"
doc.getElementById("mcity").Value = "Mississauga"
doc.getElementById("mstate").Value = "ON"
doc.getElementById("hphone").Value = "1111111"
doc.getElementById("emailConfirm").Value = "75871#kff.com"
doc.getElementsByName("SSN")(0).Value = "000000000"
doc.getElementById("password").Value = "password1"
doc.getElementById("passwordconfirm").Value = "password1"
doc.getElementsByName("securityanswer")(0).Value = "pizza"
doc.getElementsByClassName("btn btn-primary")(0).Click
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
'Third Screen'
Set tags = doc.getElementsByClassName("btn btn-success")
For Each tagx In tags
If tagx.Name = "submitfinish" Then
tagx.Click
End If
Next
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
'Fourth Screen'
doc.getElementsByName("Submit3")(0).Click
'Fifth Screen'
doc.getElementsByName("CheckOrderPaid")(0).Click
doc.getElementsByName("Shipped")(0).Click'
doc.getElementsByName("subAdminOpt")(0).Click
Flag
End Sub
Below is the HTML code for the troublesome button:
<input name="submitfinish" class="btn btn-success" type="submit" value="Finish Order">
I am not sure why the actions I used in the first 2 pages to click the submit button are suddenly not working on the third page. I have tried may different iterations trying to work around the problem but have yet to find one that is successful.
Appreciate any feedback.
Additional DOM Details:
<div class="text-right">
<a class="btn btn-default" href="/default.asp?guid=651F5B01-725B-4CCD-B12E-17CD5D59C472">Continue Shopping<!--Continue Shopping--></a>
<input name="submitcalc" class="btn btn-default" type="submit" value="Re-Calculate">
<input name="submitfinish" class="btn btn-success" type="submit" value="Finish Order"><!--Finish Order -->
</div>
Entire webpage HTML:
<!DOCTYPE html>
<html lang="en" class="non-mobile">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<meta content='width=device-width, initial-scale=1.0, maximum-
scale=1.0, user-scalable=0' name='viewport' />
<!-- Scripts -->
<script type="text/javascript" src="//code.jquery.com/jquery-
1.11.0.min.js"></script>
<script type="text/javascript" src="/common/script.js"></script>
<script type="text/javascript" src="/common/function/script_source.js"></script>
<script type="text/javascript" src="/common/jquery/jquery.validate.min.js"></script>
<script type="text/javascript" src="/common/function/functions.js"></script>
<!-- bootstrap -->
<script type="text/javascript" src="/responsive/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/responsive/js/common.js"></script>
<script type="text/javascript" src="/common/shadowbox/shadowbox.js"></script>
<script type="text/javascript" src="/responsive/js/jquery.animate-colors-min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.js"></script>
<script type="text/javascript" src="//unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<!-- CSS -->
<link href="/common/shadowbox/shadowbox.css" rel="stylesheet">
<link href="/responsive/css/bootstrap.css" rel="stylesheet">
<link href="/responsive/css/bootstrap-custom.css" rel="stylesheet">
<link href="/responsive/css/bootstrap-ms.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.css" rel="stylesheet">
<!-- Parent Site overrides -->
<link href="//associate.heritagerep.com/clientinc/resources/css/common.css" rel="stylesheet">
<style type="text/css">
#import url('//associate.heritagerep.com/common/templates/public/css/custom.css');
</style>
<script type="text/javascript">
$(function() {
app.init({ domain: 'associate.heritagerep.com'});
});
</script>
</head>
<body class="responsive">
<!-- This is a helper so javascript can see whether or not this is a mobile device -->
<div id="isMobile" class="visible-xs"></div>
<form method="post" name="currencyty">
<input type="hidden" name="CartId" value="439915">
<table class="table table-striped">
<thead>
<tr>
<th>ItemCode<!--ItemCode--></th>
<th>Description<!--Descr--></th>
<th>Qty<!--Qty--></th>
<th>Currency<!--Currency--></th>
<th>Price Each<!--Price Each--></th>
<th>
Volume
</th>
<th>Volume 2<!--Volume 2--></th>
<th>Price Total<!-- Total--></th>
<th>
Points Total
</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td> <!-- ITEM CODE -->
1004
</td>
<td><!-- Description -->
Initial Certification Fee
</td>
<td> <!-- QTY -->
<input name="Qty_609000021&609000020&0&-1&1004&N" type="text" value="1" size="2" onblur="WidthTest(this,1);" />
</td>
<td>CAD</td>
<td>
$25.00
</td>
<td>
0
</td>
<td>
0
</td>
<td>
$25.00
</td>
<td>
0
</td>
<td class="text-right">
Edit<!--Edit-->
</td>
</tr>
<tr>
<td colspan="100%">
<div class="pull-left">
Add Item<!--Add-->
</div>
<div class="pull-right">
<input name="adItemCode" type="text" value="Item Code" size="10" onclick="this.value = ''" onblur="WidthTest(this,1);AddTableRow('ProductItemCode')"><!--Item Code-->
Qty:<!--Qty:--> <input name="adNewQty" type="text" value="1" size="2" onblur="WidthTest(this,1);">
<span style="font-weight:bold;vertical-align: middle; float: right;">
<input type="submit" name="submitadd" value="Add Item" onclick="whichButton='add';"><!--Add Item-->
</span>
</div>
</td>
</tr>
</tbody>
</table>
<div class="pull-right">
<ul class="list-group">
<li class="list-group-item">
<strong>Volume:</strong>
0
</li>
<li class="list-group-item">
<strong>Totals<!--Totals :-->:</strong>
$25.00
</li>
</ul>
</div>
<div class="clearfix"></div>
<div class="text-right">
Continue Shopping<!--Continue Shopping-->
<input type="submit" name="submitcalc" value="Re-Calculate" class="btn btn-default">
<input type="submit" name="submitfinish" value="Finish Order" class="btn btn-success"><!--Finish Order -->
</div>
</form>
<script language="javascript">
$(function() {
$('.fancy').fancybox({
'width' : '75%',
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe',
'topRatio': '0.1',
'autoHeight': true
});
});
</script>
</body>
You could try and attribute = value selector to target element. Let us know if an error and if so check if there is a parent iframe/frame tag.
ie.document.querySelector("[value='Finish Order']").click
Or
ie.document.querySelector("[value='Finish Order']").FireEvent "onclick"

Nested Layouts MVC5

I am new to MVC so pardon if my questions come across as stupid.
I have a main layout file (_MainLayout.cshtml) and a secondary layout file (_AdminLayout.cshtml). Both these files reside in my /Views/Shared folder.
The _MainLayout.cshtml looks like:
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" type="image/x-icon" href="~/icons/favicon.ico" />
<title>U - #ViewData["Title"]</title>
<link rel="stylesheet" href="~/Content/Site.css"/>
</head>
<body>
<nav>
<div id="MainMenu" style="top:45px; height:40px; width:100%; position:fixed">
<ul style="list-style-type:none; text-align:center">
<li class="u-li-rightfloatinglink">#Html.ActionLink("Admin", "_AdminLayout", "Admin")</li>
<li class="u-li-rightfloatinglink">#Html.ActionLink("Contact", "Contact", "Home")</li>
<li class="u-li-rightfloatinglink">#Html.ActionLink("About", "About", "Home")</li>
<li class="u-li-rightfloatinglink">#Html.ActionLink("Home", "Index", "Home")</li>
</ul>
</div>
</nav>
<div id="MainBody" style="top: 80px; width:100%; text-align:center; position:fixed">
#RenderBody()
</div>
<div id="MainFooter" style="position:fixed; bottom:0px; width:100%; height:20px; background:#015da0">
<p style="display:table-cell; color:#ffffff; text-align:center; vertical-align: middle">© #DateTime.Now.Year - U</p>
</div>
#RenderSection("scripts", required: false)
</body>
The _AdminLayout.cshtml looks like:
#{
ViewBag.Title = "_AdminLayout";
Layout = "~/Views/Shared/_MainLayout.cshtml";
}
<h2>_AdminLayout</h2>
<div>
#RenderBody()
</div>
The ManageTableContent.cshtml is again supposed to be displayed in the #RenderBody section of the _AdminLayout.cshtml.
ManageTableContent.cshtml looks like:
#{
Layout = "~/Views/Shared/_AdminLayout.cshtml";
ViewBag.Title = "Manage Table Content";
}
<body>
<div class="u-div-header">
<p class="u-p-header">Manage Table Content</p>
</div>
<br />
<div style="width: 100%">
<table class="u-table-layouttable">
<tr>
<td class="u-td-description">Table Name here</td>
<td class="u-td-buttons">
<button class="u-button-addrecord" title="Add Record">
<img />
</button>
<button class="u-button-deleterecord" title="Delete Record">
<img />
</button>
<button class="u-button-clonerecord" title="Clone Record">
<img />
</button>
</tr>
<tr>
<td colspan="2">
<table id="ManagedTable" class="u-table-datatable">
<tr class="u-tr-datatable">
<td></td>
</tr>
</table>
</td>
</tr>
</table>
<table style="width: 100%">
<tr>
<td>
<input id="Submit" type="submit" value="Submit" style="float: right" />
<input id="Cancel" type="reset" value="Cancel" style="float: right" />
</td>
</tr>
</table>
</div>
</body>
For some reason if I get this error when I try and open my _AdminLayout.cshtml by selecting the Admin link from my _MainLayout.cshtml:
Additional information: The file "~/Views/Shared/_AdminLayout.cshtml" cannot be requested directly because it calls the "RenderBody" method.
Controller Code:
namespace U.Controllers
{
public class AdminController : Controller
{
// GET: Admin
public ActionResult ManageTableContent()
{
return View();
}
public ActionResult _AdminLayout()
{
ViewBag.Message = "Your admin page.";
return View();
}
}
}
If I remove the #RenderBody()from my code then the _AdminLayout.cshtml loads fine.
I need the #RenderBody() in my _AdminLayout.cshtml because here I will display partial Views again.
Any help would be appreciated.
You can only have one #RenderBody() per master layout (that's where the output of a View goes to).
If _AdminLayout.cshtml is not a master layout, then you should use #RenderPartial to insert partial views there.
Based on your comment,
when you call _AdminLayout action
then it calls automatically _AdminLayout.cshtml and as it has #RenderBody() method in his view file it get error. Action controller view can not hold #RenderBody().
you can do that way. Change your ActionResult _AdminLayout name to AdminLayout.
And create another view file named AdminLayout.cshtml.
And in that cshtml you can code this way.
#{
Layout = "~/Views/Shared/_AdminLayout.cshtml";
ViewBag.Title = "Manage Table Content";
}
I hope you understand why do you get this error.

h:selectBooleanCheckbox valueChangeListener is not working

I am facing trouble with the valueChangeListener of h:selectBooleanCheckbox. I have the following code block:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<link href="../css/profile.css" rel="stylesheet" type="text/css" />
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<link href="../css/twt.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="../js/custom-form-elements.js"></script>
<a4j:form id="userList">
<a4j:outputPanel id="userListPanel" rendered="#{popupController.iIndex >= 0}">
<div id="listPopup_#{popupController.iIndex}"
style="width: 202px; height: 235px; position: absolute; right: 0%; display: none; z-index: 10000;
background-image: url('../images/Alert/createNewListBack.gif'); background-repeat: no-repeat;">
<table width="180" cellpadding="0" cellspacing="0" height="100%" style="margin-top: 6px; margin-left: 10px;">
<a4j:repeat id="userListRepeat" value="#{popupController.userList}" rowKeyVar="i" var="listByUser">
<tr>
<td valign="middle" align="center" width="35" style="padding-left: 8px;">
<h:selectBooleanCheckbox id="listCheckbox_#{i}" name="listCheckbox_#{i}"
valueChangeListener="#{popupController.addUserListMember}" immediate="true">
</h:selectBooleanCheckbox>
</td>
<td valign="middle" align="left" class="alertSelect" width="145">
<div style="width: 170px; height: auto; word-wrap: break-word; white-space: pre-wrap;">
<h:outputText style="padding-right: 8px;" value="#{listByUser.name}" />
</div>
</td>
</tr>
</a4j:repeat>
</table>
</div>
</a4j:outputPanel>
</a4j:form>
</ui:composition>
And the addUserListMember of PopupController is
public void addUserListMember(ValueChangeEvent event) throws Exception {
System.out.println("=========================== PopupController.addUserListMember() ==================");
Boolean isChecked = (Boolean) event.getNewValue();
if(isChecked) {
System.out.println("===== Checked =====");
} else {
System.out.println("===== Un Checked =====");
}
}
But the valuechangelistner is not working. I can't use this.form.submit() because it will not fit into the code. I am in jsf 1.2.
What is the remedy? Thanks.
The valueChangeListener is not a client side event/happening. It's fully server side. You should really submit the form to the server side after you change the value in order to get it invoked.
As you're apparently already using Ajax4jsf, you could just add an <a4j:support>.
<h:selectBooleanCheckbox ...>
<a4j:support event="onclick" reRender="someOtherComponentIfNecessary" />
</h:selectBooleanCheckbox>

Resources