我有一个页面上有一堆用户控件.我希望能够在我的代码中替换的内容中直接使用"宏"或"占位符".这应该不重要,但我使用Ektron作为我的CMS.
在发送到客户端之前,是否有任何页面事件可以挂钩以对整个呈现的页面内容进行字符串替换?
UPDATE
这是我目前用来完成此任务的代码:
protected override void Render(HtmlTextWriter writer)
{
string content = string.Empty;
using (var stringWriter = new StringWriter())
using (var htmlWriter = new HtmlTextWriter(stringWriter))
{
// render the current page content to our temp writer
base.Render(htmlWriter);
htmlWriter.Close();
// get the content
content = stringWriter.ToString();
}
// replace our placeholders
string newContent = content.Replace("$placeholder1$", "placeholder1 data").Replace("$placeholder2$", "placeholder2 data");
// write the new html to the page
writer.Write(newContent);
}
Run Code Online (Sandbox Code Playgroud) 我UIElement想要捕获用户单击按钮时的快照.当用户单击该按钮时,我想将UIElement其当前状态加载到Image元素中.我如何渲染UIElement为Image?
我正在尝试使用xslt设置rss Feed的样式.我想显示存储在Feed中标记中的图像.问题是它被编码为在页面上显示为文本而不是被渲染.以下是字符串的一部分示例.
1).<description>< img src ="http:// buavhw.blu.livefilestore.com/ y1ppCokLxFJSG2cmyPdvg ...
我不得不在上面的字符串中添加额外的编码,以使其在此处正确显示.下面的字符串是我将其直接粘贴到文本框中时的显示方式.
2).<description> <img src ="http:// buavhw.blu.livefilestore.com/ y1ppCokLxFJSG2cmyPdvg ...
如果我从预览窗口再次复制并粘贴它,它只会变成以下字符串.
3).<description> <img src ="http://buavhw.blu.livefilestore.com/y1ppCokLxFJSG2cmyPdvg ...
我遇到了需要为Mailchimp准备时事通讯的rake任务.
使用rails 2.x东西googled我现在有这个代码:
desc "Sends newsletter to Mailchimp list"
task :send_newsletter => :environment do
begin
# get render helpers
av = ActionView::Base.new(Rails::Application::Configuration.new(Rails.root).view_path)
av.class_eval do
include ApplicationHelper
end
things = Stuff.do.things
h = Hominid::Base.new({:api_key => "xxx"})
h.create_campaign(
{
:list_id => "xxx",
:subject => "Hey...",
:from_email => "xxx",
:from_name => "xxx",
:to_email => "",
:auto_footer => true,
:generate_text => true
},
{
:html => av.render(:template => "stuff/newsletter", :locals => {:things => things}, :layout => false)
},
"regular")
rescue Exception => e
STDERR.puts …Run Code Online (Sandbox Code Playgroud) 我使用的是grails-1.3.2和hbase-0.2.4.
我有以下域类:
class MyClass{
String val1
String val2
String val3
//----
}
class MyClassController{
def someAction = {
def myClass = new MyClass()
//----
String valAsJson = (myClass as JSON)
render valAsJson
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,是否有任何简短的方法只渲染部分属性(例如渲染除val3属性以外的所有属性)?
我正在寻找一种方法来加载页面并将渲染保存为图像,就像使用CutyCapt一样(QT + webkit EXE就是这样).
目前并且没有JavaFX,我通过从java调用外部进程并渲染到文件而不是将该文件加载到ImageBuffer中来实现...既不优化也不实用,甚至更少跨平台...
使用JavaFX2 +我尝试使用WebView和WebEngine:
public class WebComponentTrial extends Application {
private Scene scene;
@Override
public void start(final Stage primaryStage) throws Exception {
primaryStage.setTitle("Web View");
final Browser browser = new Browser();
scene = new Scene(browser, 1180, 800, Color.web("#666970"));
primaryStage.setScene(scene);
scene.getStylesheets().add("webviewsample/BrowserToolbar.css");
primaryStage.show();
}
public static void main(final String[] args) {
launch(args);
}
}
class Browser extends Region {
static { // use system proxy settings when standalone application
// System.setProperty("java.net.useSystemProxies", "true");
}
final WebView browser = new WebView();
final …Run Code Online (Sandbox Code Playgroud) 我有以下型号:
public class ContractPlain
{
public int Id { get; set; }
public Guid ContractGuid { get; set; }
public int SenderId { get; set; }
public int RecvId { get; set; }
public int ContractType { get; set; }
public string ContractStatus { get; set; }
public DateTime CreatedTime { get; set; }
public DateTime CreditEnd { get; set; }
}
public class Contrtacts
{
List<ContractPlain> listOutput;
public void Build(List<ContractPlain> listInput)
{
listOutput = new List<ContractPlain>();
}
public List<ContractPlain> …Run Code Online (Sandbox Code Playgroud) 也许我只是在问google&co.错误的问题,但这是我想要完成的:
我有一个带有嵌套模板的GSP模板.外部实体可以访问域类实例的成员.而不是像所有域名成员一样传递
<g:render template="/image/alternativeTemplate" model="${[member1: member1, member2: member2]}"/>
Run Code Online (Sandbox Code Playgroud)
或使用迭代器之类的
<g:render template="/image/alternativeTemplate" model="${[it: it]}"/>
Run Code Online (Sandbox Code Playgroud)
我想在内部使用外部GSP模型.
我错过了什么吗?
问候,smon
我正在我的应用程序中实现一个简单的API来与Android应用程序通信.我正在尝试使用AbstractController :: Metal主要用于性能.我遇到的问题是渲染忽略了我传递的状态选项.
很简单的例子:
class Api::V1::ApiController < ActionController::Metal
include AbstractController::Rendering
include ActionController::Renderers::All
include ActionController::RackDelegation
include ActionController::MimeResponds
end
class Api::V1::SessionsController < Api::V1::ApiController
def show
render status: :unauthorized # using 401 yields the same result
end
end
Run Code Online (Sandbox Code Playgroud)
调用
curl -v -X GET http://app.dev:3000/api/v1/sessions.json
Run Code Online (Sandbox Code Playgroud)
我希望收到401,但我得到200 OK:
> GET /api/v1/sessions.json HTTP/1.1
> User-Agent: curl/7.30.0
> Host: app.dev:3000
> Accept: */*
>
< HTTP/1.1 200 OK
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?覆盖response.status是迄今为止我发现的唯一一项工作,但老实说它看起来像一个丑陋的黑客.
提前感谢您的见解.
我在Android Studio 3.4中预览生成的导航抽屉布局的问题。
我试图更改布局主题或更改预览的API版本,但是这些似乎都没有帮助。渲染问题的错误跟踪如下所示:
java.lang.IllegalArgumentException: java.lang.ClassCastException@26b35b5d
at sun.reflect.GeneratedMethodAccessor306.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at android.animation.PropertyValuesHolder_Delegate.callMethod(PropertyValuesHolder_Delegate.java:108)
at android.animation.PropertyValuesHolder_Delegate.nCallFloatMethod(PropertyValuesHolder_Delegate.java:143)
at android.animation.PropertyValuesHolder.nCallFloatMethod(PropertyValuesHolder.java)
at android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:38)
at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1387)
at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:990)
at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:674)
at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:637)
at android.animation.ValueAnimator.start(ValueAnimator.java:1069)
at android.animation.ValueAnimator.start(ValueAnimator.java:1088)
at android.animation.ObjectAnimator.start(ObjectAnimator.java:852)
at android.animation.ValueAnimator.startWithoutPulsing(ValueAnimator.java:1081)
at android.animation.AnimatorSet.handleAnimationEvents(AnimatorSet.java:1142)
at android.animation.AnimatorSet.startAnimation(AnimatorSet.java:1227)
at android.animation.AnimatorSet.start(AnimatorSet.java:729)
at android.animation.AnimatorSet.start(AnimatorSet.java:684)
at android.animation.StateListAnimator.start(StateListAnimator.java:188)
at android.animation.StateListAnimator.setState(StateListAnimator.java:181)
at android.view.View.drawableStateChanged(View.java:21105)
at android.widget.ImageView.drawableStateChanged(ImageView.java:1294)
at com.google.android.material.floatingactionbutton.FloatingActionButton.drawableStateChanged(FloatingActionButton.java:804)
at android.view.View.refreshDrawableState(View.java:21160)
at android.view.View.dispatchAttachedToWindow(View.java:18379)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:335)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:391)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:195)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:540)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$5(RenderTask.java:666)
at …Run Code Online (Sandbox Code Playgroud)