Dollar sign followed by a curly bracket inside widget html - servicenow

I am currently on the Helsinki Release
Cannot understand the purpose of dollar sign and curly braces inside label tag
<label class="control-label" for="inputSuccess">${Location}</label>
The full html of the weather widget:
<form class="form-inline well">
<div class="form-group" ng-class="{'has-error': (c.errorMessage), 'has-success': (c.channel)}">
<label class="control-label" for="inputSuccess">${Location}</label>
<input type="text" class="form-control" id="weatherInput" placeholder="{{::data.enterLocMsg}}" ng-model="c.data.place">
<button type="submit" class="btn btn-default" ng-click="c.getWeather();">${Go}</button>
<span class="help-block" ng-bind="c.errorMessage" ng-if="c.errorMessage"></span>
</div>
</form>
<div class="panel panel-default" ng-if="c.channel">
<div class="panel-body">
<p>${Location}: {{c.channel.location.city}}, {{c.channel.location.region}} {{c.location.country}}</p>
<p>${Temperature}: {{c.channel.item.condition.temp}}</p>
<p>${Condition}: {{c.channel.item.condition.text}}</p>
<p>{{c.channel.item.condition.date}}</p>
</div>
</div>

From ServiceNow Product Dokumentation
Use the HTML template to internationalize strings in a widget.
Writing text as ${message} is the equivalent of writing ${gs.getMessage("message")} in other parts of the system, but written as a more legible shorthand.

Related

ASP.NET Core MVC : can't render fields inside form tag

I'm working on a function that allows agents to check and modify on what inventory their customers bought.
Basically, it's an update form inside a bootstrap modal, which is in a partial view under another partial view.
At first, I tried to bind my view model with the form inside the modal using tag helper. Something like:
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Update Inventory</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form id="UpdateForm" asp-controller="Home" asp-action="UpdateD" data-ajax-method="post" data-ajax="true" data-ajax-success="InsertSuccess">
<div class="modal-body">
<div class="mb-3 row">
<label asp-for="FieldExample" class="col-sm-2 col-form-label">FieldExample</label>
<div class="col-sm-10">
<input asp-for="FieldExample" class="form-control">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">UpdateBtn</button>
</div>
</form>
</div>
</div>
I checked the form tag was closed properly and the data fields were valid.
But the form turns out to render none of my fields, closing immediately, like this:
<form id="UpdateForm" data-ajax-method="post" data-ajax="true" data-ajax-success="InsertSuccess" action="/Home/UpdateD" method="post"></form>
<div class="modal-body">
<div class="mb-3 row">
<label class="col-sm-2 col-form-label" for="PLAN_TYPE">FieldExample</label>
<div class="col-sm-10">
<input class="form-control" type="text" id="FieldExample" name="FieldExample" value="test">
</div>
</div>
(...other fields)
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">UpdateBtn</button>
</div>
<input name="__RequestVerificationToken" type="hidden" value="...">
</div>
The form doesn't include my data fields for some reason, and I don't know what is making it wrong.
Even if I tried to make a form using a simple form tag with test fields inside, the form is still malformed (with no fields inside).
It will be thankful for me if some suggestions come up (sorry for my language)
After struggling a few days on this issue, I finally solved the problem by adding <td></td> on the <partial>.
Since the partial was rendered in a <table>, but wasn't nested in a <td> tag.
Adding partial view to a <td> tag seems to make the syntax more valid in my case. The form in the partial view will render with it's data field perfectly.

How to use laravel shweshi/OpenGraph

Here how to use it according to its GitHub
I already install the package:
Use Opengraph
$data = OpenGraph::fetch("http://www.addemyplus.com/blogs/my-faith-for-your-love");
that may return an array:
{"type":"website","title":"My Faith For Your Love","description":"","image":"http:\/\/www.addemyplus.com\/images\/frontend_images\/blogs\/medium\/57670.jpg"}
My problem is how can I use it on my blade that whenever I type a link in the form it will fetch the Og data of that site.
and show below the image and description
I have this code on form:
<form action="{{route('store_post_path')}}" method="POST">
{{csrf_field()}}
<div class="form-group">
<label class="sr-only" for="title">title</label>
<input type="text" class="form-control" name="title" placeholder="Your Post Title or Question">
</div>
<div class="form-group">
<label class="sr-only" for="post">post</label>
<textarea class="form-control" name="post_content" id="post_content" rows="3" placeholder="Briefly explain your question or Your Post Content"></textarea>
</div>
<div class="tab-pane fade" id="images" role="tabpanel" aria-labelledby="images-tab">
<div class="form-group">
<div class="custom-file">
</div>
</div>
<div class="py-4"></div>
</div>
<div class="btn-toolbar justify-content-between">
<div class="btn-group">
<button type="Submit" class="btn btn-primary">Share your Post</button>
</div>
</div>
</form>
How can I use the code to fetch the Og property of the link? I want to view the image and title of the link below before submitting my post.. Please show some tutorial sites for this.
Get the link from the form in post content. You can do it using regex.
function getUrl($string)
{
$regex = '/https?\:\/\/[^\" ]+/i';
preg_match_all($regex, $string, $match);
return ($match);
}
$url = getUrl($string)
If there are any links in post content you will get array of links.
Use OpenGraph::fetch($url) to fetch the OG data of the url. That you can show in the view.

New to Laravel, trying to integrate Square Payment Form

I've been following the instructions on Square's website.
I've got all the code I need plugged into my application as shown on square, but the asset('js/square.js') call didn't find the file for some reason. So, I just added the script to the end of the resources/js/app.js file, doesn't seem to have any errors but the form doesn't look right..
<form id="nonce-form" novalidate action="PATH/TO/PAYMENT/PROCESSING/PAGE" method="post">
#csrf
<fieldset>
<span class="label">Card Number</span>
<div id="sq-card-number"></div>
<div class="third">
<span class="label">Expiration</span>
<div id="sq-expiration-date"></div>
</div>
<div class="third">
<span class="label">CVV</span>
<div id="sq-cvv"></div>
</div>
<div class="third">
<span class="label">Postal</span>
<div id="sq-postal-code"></div>
</div>
</fieldset>
<button id="sq-creditcard" class="button-credit-card" onclick="requestCardNonce(event)">Pay $1.00</button>
<div id="error"></div>
<!--
After a nonce is generated it will be assigned to this hidden input field.
-->
<input type="hidden" id="card-nonce" name="nonce">
</form>

Integrate ckeditor in asp.net core mvc

I need to integrate an web based html editor in asp.net core project. I downloaded CKEditor and placed the unzipped folder in wwwroot folder.
I have referenced "ckeditor.js" in _Layout.cshtml using following script tag.
<script src="~/ckeditor/ckeditor.js" type="text/javascript">
</script>
Then, I've used following code to display the editor.
<textarea id="editor1" name="editor1">
</textarea>
<script type="text/javascript">CKEDITOR.replace('editor1');</script>
On using these lines of code in the empty About.cshtml of Home Folder, the editor was displayed. But the editor was not displayed when using the same code in another .cshtml file. The Code is given below
<div class="panel">
<div class="panel-heading border">
Create User
</div>
<div class="panel-body">
<div class="row no-margin">
<div class="col-lg-12">
<form asp-action="Edit" class="form-horizontal bordered-group" role="form">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="_id" />
<div class="form-group">
<label asp-for="Subject" class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<input asp-for="Subject" class="form-control" />
<span asp-validation-for="Subject" class="text-danger" />
</div>
</div>
<div class="form-group">
<label asp-for="MailFrom" class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<input asp-for="MailFrom" class="form-control" />
<span asp-validation-for="MailFrom" class="text-danger" />
</div>
</div>
<div class="form-group">
<label asp-for="Body" class="col-sm-2 control-label"></label>
<div class="col-sm-10">
#* CKEDitor *#
<textarea id="editor1" name="editor1">
</textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" value="Update" class="btn btn-default" />
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">CKEDITOR.replace('editor1');</script>
Why is the editor not displayed in another cshtml file?
I've also faced the same problem while integrating CKEditor in aps.net mvc project. After trying to determine the error I found that the Layout of the page is different. You may have the same problem.
Use id attribute and use a hash on the name.
<script type="text/javascript">CKEDITOR.replace('#editor1');</script>

How to use JSON response for clone tables?

Here my code consists 2 fields(1.select field, 2.input filed),i am displaying data into these fields based on id's (using json data through ajax call)like ($("#allergictoId").val(data.allergy.allergicTo1)).Now my requirement changed like if i click on button (save and add allergy)the copy of that is added to previous code.Once he added clones and clicks on save the entire data will saved on database.Now he clicks again edit i can display the entire data with clones jsp code.Here is my jsp code
<div id="divHideAllergies" class="clone">
<div class="copy">
<div class="col-md-12">
<div class="portlet box carrot ">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-medkit"></i> Allergies
</div>
</div>
<div class="portlet-body form">
<div class="form-body">
<div class="form-group">
<label class="control-label col-md-3">Allergy Type:</label>
<div class="col-md-9">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-medkit"></i></span>
<select class="form-control" id="allergy_type">
<option selected value="">--Select One--</option>
<option value="Drug">Drug</option>
<option value="Environmental">Environmental</option <option value="Food">Food</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3">Allergic to:</label>
<div class="col-md-9">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-medkit"></i></span>
<input type="text" class="form-control" name="first name" id="allergictoId"/>
</div>
</div>
</div>
</div>
</div><a class="btn btn-lg green pull-right" id="addallergy">Save and Add Allergy <i class="fa fa-plus"></i></a>
<a class="btn btn-lg red" id="removeallergy"><i class="fa fa-times"></i> Cancel</a>
</div>
</div>
</div>
</div>
</div>
I am not sure I can understand your question at 100% but here are some thoughts:
Check the "Processing JSON objects in JSP" question. Here they are using scriptlets but you can do basically the same with JSTL.
Your JSP seems to have lack of JSP code in it - it is just a HTML - and that's fine, but you can consider using JavaScript to process you JSON response since it is so much natural (at least to me).

Resources