ElException method not found - java-ee-5

I work in a project using seam and jsf. I want to call a method from view part (an xhtml file) .
I have this:
<h:outputText value="#{thePoliciesAdmin.getMinusUsage()}"/>
I have the method created in thePoliciesAdmin class but when I run the app I get the following exception:
javaxElException ..Method not found : thePoliciesAdmin.getMinusUsage().
What can I do?

Related

Umbraco add dashboard with code

Ok, with some help I found the code to add a new application / section without modifying the config manually. Add an assmebly with this class in the /bin folder and the section is automatically added to Umbraco.
[Application("guestbook", "Guestbook", ".trayguestbook", 20)]
public class Class1 : IApplication
{
Then you can modify the Tree by adding a class that inherits from BaseTree.
[Tree("guestbook", "guestbookTree", "Guestbook")]
public class Class2 : BaseTree
{
Is there a way to modify the dashboard with a similair approach as well?
Thanks!
As far as I know, there isn't a code first approach to modifying the dashboard.config. However, if you wrap your project into an Umbraco package, you can use package actions to add a dashboard section. Here's an example from the documentation:
<Action runat="install" alias="addDashboardSection" dashboardAlias="MyDashboardSection">
<section>
<areas>
<area>default</area>
<area>content</area>
</areas>
<tab caption="Last Edits">
<control>/usercontrols/latestEdits.ascx</control>
<control>/usercontrols/PostCreate.ascx</control>
</tab>
<tab caption="Create blog post">
<control>/usercontrols/new.ascx</control>
</tab>
</section>
</Action>
For more details on package actions see Package Action Samples. For more information of creating Umbraco packages see How to create a project package for Umbraco?.

backbone/marionette attaching HTML into a region

I'm beginning to use Marionette within an existing backbone application. I've got some HTML which I want to append into a region. In pure backbone, I could just do this.$el.append(html_code) and that was all. As far as I can see, marionette regions allow only to operate on views (which have to implement the render method). Calling append on marionette region throws 'undefined method' errors.
Is it possible to attach plain HTML to a marionette region?
No, it's not possible to inject plain html into a Marionette.Region.
Theoretically you could access a regions DOM element with someRegion.el or someRegion.getElement(), but this must be done after rendering (which at least isn't possible inside a Marionette.View with standard behaviour).
But you can achieve the desired result by using a specially crafted Marionette.ItemView:
#someRegion.show(new Marionette.ItemView({template: '<h1>gach</h1>'}));
You maybe also should have a look at Marionette.Renderer .
a Marionette ItemView will look for a template and will call render on that template, so when you show the view in the region the html will be displayed just fine with out the need of you defining a render method.
MyImtemView = Backbone.Marionete.ItemView.extend({
template : "#myTemplate"
});
var myItemView = new MyItemView();
myLayout.aregion.show(myItemview);
this should work if you save your html in a template like this
`<script id="myTemplate" type="text/template">
<div><p>your html<p>
</div>
`
EDIT
you can also declare a render function in your view in case you need to generate and modify your html like this.
MyImtemView = Backbone.Marionete.ItemView.extend({
template : "#myTemplate",
render : function (){
this.$el.append(HMTL); //so here you work your html as you need
}
});
var myItemView = new MyItemView();
myLayout.aregion.show(myItemview); //the render function of your view will be called here
I ran into the same problem and tried the answers explained here, but I'm also using require.js and kept getting an error for the #my_view template not being found. If anyone can clarify where does Marionette look up the templates by default, that would be great.
Instead, I solved it by using the text.js plugin for underscore.js. This way you actually can use a plain html file as the template, without the need for nesting it in a script tag. Here's how I did it.
define(['backbone', 'underscore', 'marionette', 'text!tmpl/my_view.html'], function(Backbone, _, Marionette, view_t){
var MyView = Backbone.Marionette.ItemView.extend({
template : function(serialized_model) {
//define your parameters here
param1 = erialized_model.param1;
return _.template(view_t)({
param1: param1
});
}
});
return MyView;
});
I placed the text.js plugin in the same lib directory as all my other js libraries and my main.js for require declares the path to the templates as
'tmpl': '../../templates',
My project structure looks like this
root
index.html
js
main.js
app
App.js
views
MyView.js
lib
require.js
text.js
backbone.js
underscore.js
jquery.js
backbone.marionette.js
templates
my_view.html
My template 'my_view.html' simply looks like this.
<h1>THIS IS FROM THE TEMPLATE!!!</h1>
Worked perfectly. I hope you find it useful.
Using a view
var myHtml = '<h1>Hello world!</h1>';
var myView = new Marionette.ItemView({template: _.constant(myHtml)});
myRegion.show(myView);
Marionette.Renderer.render takes either a function or the name of a template (source code). _.constant creates a function that returns the passed-in parameter.
Attaching HTML
Alternately, the docs for Marionette.Region mention overriding the attachHtml method, see Set How View's el Is Attached.

Call view.phtml template in custom layout

I am new in magento i am getting issue while calling the view.phtml file in custom layout.
Folowing is my code which is i am including in cutom layout file but i am getting Fatal error
Fatal error: Call to a member function getMetaTitle() on a non-object in D:\wamp\www\projects\magento\app\code\core\Mage\Catalog\Block\Product\View.php on line 56.
<?php echo $this->getLayout()->createBlock('catalog/product_view')->setTemplate('catalog/product/view.phtml')->toHtml(); ?>
Please reply me for this issue.
Thanks in advance.
Your error occurs in the file D:\wamp\www\projects\magento\app\code\core\Mage\Catalog\Block\Product\View.php on this line
$product = $this->getProduct();
$title = $product->getMetaTitle();
When you create a block you do not specify a product for which the block is created, and this is an important and required parameter.
Function to get the product :
public function getProduct()
{
if (!Mage::registry('product') && $this->getProductId())
{
$product = Mage::getModel('catalog/product')->load($this->getProductId());
Mage::register('product', $product);
}
return Mage::registry('product');
}
Do you actually have one option how to fix this problem, but it is not quite beautiful, but working.
<?php
Mage::register('product',Mage::getModel('catalog/product')->load(YOUR_PRODUCT_ID));
echo $this->getLayout()->createBlock('catalog/product_view')->setTemplate('catalog/product/view.phtml')->toHtml();
Mage::unregister('product');
?>
This decision can not be used on the product page.
You shouldn't instantiate a Block like that.
Take a look at the standard product page to understand how it works :
You have a controller named catalog/product/view wich is defined in the Mage_Catalog_ProductController class
This controller is linked to a Layout update handle defined in the catalog.xml file in app/design/package/theme/layout/catalog.xml
In this layout file, you'll see that the block catalog/product_view is declared with a few children :
<catalog_product_view translate="label">
[...]
<reference name="content">
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
<block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml"/>
<block type="core/text_list" name="alert.urls" as="alert_urls" translate="label">
<label>Alert Urls</label>
</block>
[...]
This this the part you're missing by instantiate it manually.
You must adapt/understand the layout in catalog.xml for your needs
Good luck

Fill in a ArrayList within a configuration jelly file for a Jenkins Plugin

I have a problem when trying to implement the configuration file of my plugin.
I started my program with the already existing SideBar Plugin, but I encountered a problem when I added a List<String> as a variable to the class Action : private List<String> projects;
How can I fill such a list within the jelly file?
I tried doing as such :
<f:entry>
<f:optionalBlock title="Project to be considered :">
<f:repeatable var="project" items="${link.projects}" name="projects" add="Add a project">
<f:entry title="Project 1 :">
</f:entry>
</f:repeatable>
</f:optionalBlock>
</f:entry>
I added these lines in the links.jelly file, but it doesn't work.
If anyone knows how to do this, it would be great.
Thank you
The list in your action should have a type (also for better reading)
private List<YourObject> projects
Then your config.jelly can look like this:
<f:repeatable var="projectInList" name="projects" items="${instance.projects}" noAddButton="true" minimum="0">
<fieldset>
<f:entry title="${%Project}" description="Project desc."
field="variableInProjectObject">
<f:textbox value="${projectInList.variableInProjectObject}" default="" />
</f:entry>
</fieldset>
</f:repeatable>
I fixed similar problem this way:
<f:entry title="Parameters" field="projects">
<f:repeatableProperty field="projects" minimum="1" />
</f:entry>
Thanks to this resource

Razor views as email templates

I am creating an email engine in mvc3 and I am trying to use razor views as email templates.
I heard this is possible but I have not yet found any information about it.
You can use http://razorengine.codeplex.com/ to achieve this. It allows you to use razor outside of mvc.
string Email = "Hello #Model.Name! Welcome to Razor!";
string EmailBody = Razor.Parse(Email, new { Name = "World" });
It's simple to implement and it's available on http://nuget.codeplex.com/ for easy integration into your projects.
You CAN use a template file to serve as a razor email body template. You can use whichever extension you choose because you can load a file as text in .Net. Let's use the following example for the template:
Hello #Model.Name,
Welcome to #Model.SiteName!
Regards,
Site Admins
Save that file as something like "WelcomeMessage.cshtml", "WelcomeMessage.template", etc. Select the file in Solution Explorer and in the Properties window, select "Copy to Output Directory" and choose "Copy Always". The only down point is that this template has to accompany the application and doesn't compile as a class.
Now we want to parse it as a string to assign to a mail message body. Razor will take the template and a model class, parse them, and then return a string with the necessary values.
In your application you will need to add the RazorEngine package which can be found with NuGet. Here's a short code example to illustrate the usage:
using System.IO;
using RazorEngine;
// ...
MyModel model = new MyModel { Name = "User", SiteName = "Example.com" };
string template = File.OpenText("WelcomeMessage.template").ReadToEnd();
string message = Razor.Parse(template, model);
It's similar to the other answers but shows a quick way to load the template from a text file.
You should perhaps consider MvcMailer. RazorEngine is (very) good if you aren't already using MVC (I've used it successfully in a webforms context), but if you have MVC you may as well take advantage of it.
(via Hanselmen's NuGet package of the week 2)
You can also use Essential Mail: Razor package from NuGet. It is build over RazorEngine and provides simple interface for email rendering.
Email message template looks something like
#inherits Essential.Templating.Razor.Email.EmailTemplate
#using System.Net;
#{
From = new MailAddress("example#email.com");
Subject = "Email Subject";
}
#section Html
{
<html>
<head>
<title>Example</title>
</head>
<body>
<h1>HTML part of the email</h1>
</body>
</html>
}
#section Text
{
Text part of the email.
}
Read more on GitHub: https://github.com/smolyakoff/essential-templating/wiki/Email-Template-with-Razor
Mailzor
Linked to what #thiagoleite mentioned, I took Kazi Manzur Rashid's idea (with permission) and extended in to be more friendly for how I wanted to use it.
So check out the github project 'mailzor'
It's also up on Nuget.org/packages/mailzor