Telerik Html.Grid Style Sheet issue - asp.net-mvc-2

I started using the Telerik Html.Grid today and have already run into a problem. The Grid itself is appearing, but text based so i know this is a style sheet issue. Also, i have been following the usage instructions with the documentation. Ill go through them and explain what i did, maybe my interpretation was wrong.
1)Open an existing ASP.NET MVC application in Visual Studio or create a new one.
Done
2)Add a reference to Telerik.Web.Mvc.dll which is located in the Binaries folder of Telerik Extensions for ASP.NET MVC install location:
Done
3)Register the Telerik Extensions for ASP.NET MVC namespaces:
Done, but i used import instead of add
<%# Import Namespace="Telerik.Web.Mvc.UI" %>
4)Add the JavaScript files in the Scripts folder of your ASP.NET MVC application.
Done, but essentailly the scripts are in the location Web/Scripts/2010.2.825 I also put in the ScriptRegistrar at the end of my .aspx page
<div id="footer">
<% Html.RenderPartial("SiteMasterFooter");%>
</div>
<div style="clear: both;"><!-- --></div>
<%
Html.Telerik().ScriptRegistrar().jQuery(false);
%>
5)Add the CSS files in the Content folder of your ASP.NET MVC application.
Done. Same approach as step 4, the location is Wed/Content/2010.2.825 I also put the Style sheet registrar at the head of the aspx page
<%
Html.Telerik().StyleSheetRegistrar()
.DefaultGroup(group => group.Add("telerik.common.css")
.Add("telerik.windows7.css"));
%>
6)Create a telerik web control
Done. Dont think i can screw this up, but hey.
<%
Html.Telerik().Grid(Model.Manifests)
.Name("ManifestsGrid")
.DataKeys(keys =>
{
keys.Add(p => p.Id);
})
.Columns(columns =>
{
columns.Bound(o => o.ManifestId).Width(150).Title(
"Manifest #:");
columns.Bound(o => o.Generator.CompanyName).Width(150).Title
("Company:");
columns.Bound(o => o.GeneratorFieldOffice.FacilityName).
Width(150).Title("Field Office:");
columns.Bound(o => o.GeneratorFacility.FacilityName).Width(
150).Title("Facility:");
})
.Pageable(paging => paging.PageSize(10))
.Selectable()
.Scrollable()
.Render();
%>
So i think that my problem lies with how ive added the files i need. Any input?

I fixed it actually. For anyone reading this, the problem was that i follow the guide to the letter. And take very special care as to what <% %> tags have : or = at the beginning or a ; at the end. If this is too vague post an answer to this question and ill post my code.

Related

Rails 5.2.0 - scaffold `form_with` includes `local: true` by default

When I scaffold a Rails 5.2.0 app, my scaffolded forms are always generated with the local: true option included in form_with.
rails g scaffold Article title:string
Generated scaffold form
<%= form_with(model: article, local: true) do |form| %>
<% if article.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(article.errors.count, "error") %> prohibited this article from being saved:</h2>
<ul>
<% article.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
Generated HTML
<form action="/articles/1" accept-charset="UTF-8" method="post">
Note the lack of data-remote attribute
Documentation
I thought the default for form_with in Rails 5.1.2+ was to use remote AJAX / xhr requests with data-remote attributes? In other words, NOT include the local: true option.
See: http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_with
By default form_with attaches the data-remote attribute submitting the form via an XMLHTTPRequest in the background if an Unobtrusive JavaScript driver, like rails-ujs, is used. See the :local option for more.
Note - rails-ujsgem was moved into Rails itself in 5.2.0 - https://github.com/rails/rails-ujs. So it looks like I should not need to add anything to the gemfile to enable the default form_with behavior.
Troubleshooting
I do use a .railsrc and a rails template file to customize my rails new scaffolds. However, I have tried disabling & removing both files and still get same results from new scaffolded apps.
To give a more complete answer based on my comment, here's how to add a template to customize the form partial generated by Rails when using the scaffold generator. I'm assuming here that you're using ERB, but the procedure is similar if you're using something like slim-rails to customize your view generators.
Create a file in your Rails project: lib/templates/erb/scaffold/_form.html.erb.tt
For this new file's content, a good place to start from is the content in the existing template. You can use gem which rails to locate the file that defines Rails in your current environment (with a result like /home/<user>/.rvm/gems/ruby-2.5.0#<gemset>/gems/railties-5.2.0/lib/rails.rb), and from there you can find the form template in railties-5.2.0/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt. Copy the contents of that file into your new generator template.
Try making some changes to the new template file, and then run the rails scaffold generator (rails g scaffold foo ...). You should see your changes reflected in the _form.html.erb file created by the generator.
Bear in mind that this template is 'doubly nested' ERB, meaning that it is processed with ERB a first time to produce a view partial, and then processed again every time your Rails app serves a request with it. That said, it's usually not too mind-melting to make a simple change, such as removing local: true from your new template
In depth info on customizing Rails generators is available at RailsGuides.
Think I found answer - and it's simple :) - the Rails scaffold templates for 5.2.0 explicitly include the local: true option.
5.2.0 Template for forms
<%%= form_with(model: <%= model_resource_name %>, local: true) do |form| %>
So I guess they wanted local: true as the default template for scaffolds. Probably for simplicity?
To find the scaffold generator templates
Thanks to this post for helping find the source: Override Rails scaffold generator
Find where your gems live with gem enviornment command
I use rbenv, so mine are at ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems
cd into that file and look for railties-5.2.0
search in rails/generators/scaffold/templates, or just search for local: true
here's the path: ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt

Change the friendly URL of a web content in Liferay

I am currently using an article display page to display my web content in Liferay 6.2. I'm trying to figure out how to edit the path of my friendly URL after the /-/.
Current URL: siteName/-/articleName
Desired URL: siteName/-/topicSection/articleName
You are talking about the attribute JournalArticle.urlTitle. The problem is, that there is no UI in Liferay, which lets you change that attribute (at least not out of the box).
You've got two options:
If you just want to change an existing article, you can change that attribute in the database (I'd guess that the additional / is no problem):
UPDATE JournalArticle
SET urlTitle = 'topicSection/articleName'
WHERE urlTitle = 'articleName'
If you want to offer an UI for editing that attribute, you could write a hook.
Here a short summary how to write such a hook:
Add this lines to your liferay-hook.xml:
<portal-properties>portal.properties</portal-properties>
<language-properties>Language.properties</language-properties>
<custom-jsp-dir>/WEB-INF/custom_jsps</custom-jsp-dir>
Create a file portal.properties in the Java source directory and add this line:
journal.article.form.update = urlTitle
Create a file Language.properties in the Java source directory and add this line:
urlTitle = Friendly URL
Add a file WEB-INF/custom_jsps/html/portlet/journal/article/urlTitle.jsp into the web content folder:
<%# include file="/html/portlet/journal/init.jsp" %>
<% JournalArticle article = (JournalArticle)request.getAttribute(WebKeys.JOURNAL_ARTICLE); %>
<aui:model-context bean="<%= article %>" model="<%= JournalArticle.class %>" />
<h3>Friendly URL</h3>
<aui:input name="urlTitle" />

unable to instantiate CQ.utils.WCM in cq publish mode

I'm unable to instantiate CQ.utils.WCM in CQ publsih mode to get pagePath using the function CQ.utils.WCM.getPagePath(), but I can able to get the pagePath in CQ Author mode using the same function. Can somebody help me why
CQ.utils.WCM.getPagePath() function not executing in jsp file in cq publish crxde lite
Thank you for your help!
Naren
Possibly because your AEM specific client libraries would not have been included in publish mode (i.e., when WCMMODE is disabled) and this is an ideal scenario.
The clientlibs might have been included as shown below
<% if(WCMMode.fromRequest(request) != WCMMode.DISABLED) { %>
<cq:includeClientLib categories="cq.widgets" />
<%-- or --%>
<cq:includeClientLib categories="cq.wcm.edit" />
<% } %>

Problems with Zend_Lucene when using Routes

I have implemented Zend_Lucene in my first Zend Framework Project, but since I have implemented Routes the Search Results does not seem to work anymore.
In my Search Result view, I have changed the URL to the Postdetails to use the Route:
<a href="<?php echo $this->url(array('post' => $value['post_id'], 'postname' => $value['post_title']), 'postdetails', true); ?>">
Unfortunately it does not seem to work, instead it shows me
<a href="/%3C%21DOCTYPE+html+PUBLIC+.......
I normally also use
$this->escape($value['post_title'])
but again, it shows something with DOCTYPE. I don't understand enough about ZF to know what goes wrong. Can someone give me a hint? Thank you very much in advance!
Have you tried using your named route without setting the reset option to true? I think you might be contradicting your self. You are telling the url helper to use a named route at the same time telling it to use the default routes. if you haven't already try:
<a href="<?php echo $this->url(array('post' => $value['post_id'], 'postname' => $value['post_title']), 'postdetails'); ?>">
you also may need to set default values for post and postname in your route(if you haven't already)

SiteFinity 4.0: Trouble Accessing Postback Data in Custom User Control

I'm trying to get a highly customized hand built form into sitefinity 4.0 and my problem is that no matter what I do I can't access the form's postback data in the code behind. My form is a user control and I've added it in the way described here:
http://www.sitefinity.com/40/help/developer-manual/controls-adding-a-new-control.html
After struggling for several hours, I created a basic test form and I'm still not able to access the postback data. I've also tried adding EnableViewState="true" all over the place but the form data is still empty on postback. The exact same user control runs and posts data perfectly outside of sitefinity. I also tried other methods of accessing the postback data and I discovered that Request.Form does contain the data I need. I'd still love to access my form elements in the usual way though, so I don't have to do Request.Form for every control on the page and loop that way, which seems really hokey.
Here's the code for the basic form:
"BasicUserControl.ascx"
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="BasicUserControl.ascx.cs" Inherits="SitefinityWebApp.UserControls.Assessments.BasicUserControl" EnableViewState="true" %>
<div id="assessmentDiv" runat="server">
<asp:TextBox ID="TextBox1" runat="server" clientidmode="Static" enableviewstate="true"></asp:TextBox>
<asp:Literal ID="Literal1" runat="server" clientidmode="Static" enableviewstate="true"></asp:Literal>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
"BasicUserControl.ascx.cs" Code Behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace SitefinityWebApp.UserControls.Assessments
{
public partial class BasicUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
Literal1.Text = TextBox1.Text;
}
}
}
}
Again, if I add the control via the method described at the link above, I am able to successfully create a Sitefinity 4.0 CMS page, drag the control onto it, run the page, step into the code behind using the debugger, yet when VS2010 reaches the line below there is no form data being posted:
Literal1.Text = TextBox1.Text;
FYI: The reason why there is no form tag in my usercontrol.ascx code above is because I get an error when running the form thru sitefinity that only one server-side form tag can exist on a .net page (sitefinity injects it's own form tag).
Thanks in advance for your help!
Ben
Never mind - I figured it out. For some reason, data isn't available at the Page_Load stage of the .net page lifecycle in a sitefinity form submission (at least not via a custom user control). If I wait until the Page_PreRender stage to retrieve the data from the form on the page, it's all there.
My current prevailing theory is that Sitefinity 4.0 grabs the postback data when a form submits and hasn't finished monkeying around with it at the Page_Load stage, so you have to wait until the Page_PreRender stage before sitefinity has injected the data back into the page cycle.
I had the same issue you did and came to the same solution. Spent a bunch of time on it - wish this answer had been around then.
Try adding enableviewstate into masterpages. I had the same situation and solved with this.
Also checked "enable view state" when creating pages.
Hope this help.
`<%# Master Language="C#" AutoEventWireup="true" CodeFile="HomePageClubManavgat.master.cs" Inherits="App_Master_HomePageClubManavgat" EnableViewState="true" %>
<script type="text/C#" runat="server">
protected override void OnInit(EventArgs e)
{
this.Page.EnableViewState = true;
base.OnInit(e);
}
`