String format issue in RadGrid - string

While I'm trying to bind the string data to the Rad Grid it is not binding exact value which I have pulled from Data Base.
For Example I'm pulling the Data : - "A BC E F G" and binding the same data to the Rad Grid, the problem here is the rad grid column is trimming out all the spaces and displaying like :- "A BC EFG"
Here I need to bind the exact data which I'm pulling from Database. How do I do that?

I am unable to replicate out this issue at my end.
My code looks like this:
RadGridPage.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeFile="RadgridPage.aspx.cs" Inherits="RadgridPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadGrid ID="TempTable" runat="server" Skin="MetroTouch" PageSize="5">
<MasterTableView CssClass="TempTable" Style="border: 0; cellpadding: 0; cellspacing: 0"
AutoGenerateColumns="false">
<Columns>
<telerik:GridBoundColumn HeaderText="TempData" DataField="TempData">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="TempData" DataField="TempData">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
</div>
</form>
</body>
</html>
RadGridPage.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class RadgridPage : System.Web.UI.Page
{
public class data { public string TempData { get; set; } }
protected void Page_Load(object sender, EventArgs e)
{
List<data> gridData = new List<data>()
{
new data(){TempData="A BC E F G"},
new data(){TempData="A BC E F G"},
new data(){TempData="A BC E F G"},
};
TempTable.DataSource = gridData;
}
}
Output:

Please update your code to:
RadGridPage.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeFile="RadgridPage.aspx.cs" Inherits="RadgridPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadGrid ID="TempTable" runat="server" Skin="MetroTouch" PageSize="5" OnItemDataBound="gvSpecs_ItemDataBound">
<MasterTableView CssClass="TempTable" Style="border: 0; cellpadding: 0; cellspacing: 0"
AutoGenerateColumns="false">
<Columns>
<telerik:GridBoundColumn HeaderText="TempData" UniqueName="TempDataA" DataField="TempData">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="TempData" UniqueName="TempDataB" DataField="TempData">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
</div>
</form>
</body>
</html>
RadGridPage.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
public partial class RadgridPage : System.Web.UI.Page
{
public class data { public string TempData { get; set; } }
protected void Page_Load(object sender, EventArgs e)
{
List<data> gridData = new List<data>()
{
new data(){TempData="A BC E F G"},
new data(){TempData="A BC E F G"},
new data(){TempData="A BC E F G"},
};
TempTable.DataSource = gridData;
}
protected void gvSpecs_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
TableCell cellA = (TableCell)item["TempDataA"];
cellA.Text = cellA.Text.Replace(" ", " ");
TableCell cellB = (TableCell)item["TempDataB"];
cellB.Text = cellB.Text.Replace(" ", " ");
}
}
}

Related

Password visible in ext.net user control

User control (ascx) with a password input. Right-click, inspect - the value is visible. This doesn't happen if the password input is in an aspx.
Hmm, it seems I have to add some ramblings here, since the platform won't allow me to post this thread due to "mostly code".
Default.aspx
<%# Page Language="C#" %>
<%# Register Src="UserPassword.ascx" TagName="UserPass" TagPrefix="uc" %>
<script runat="server">
protected void Page_Load( object sender, EventArgs e )
{
if ( !X.IsAjaxRequest )
{
this.BindUser();
}
}
public void BindUser()
{
userPass1.UserName = "AliBaba";
userPass1.Password = "OpenSesame";
}
</script>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Password inspect bug</title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server" />
<ext:Window
ID="Window1"
runat="server"
Icon="User"
Closable="false"
Title="Customer Details"
Width="350"
Height="230"
Resizable="false"
BodyStyle="background-color:#fff;"
BodyPadding="5"
Layout="Anchor">
<Items>
<ext:Panel ID="panel1" runat="server" Header="false" Layout="FitLayout">
<Content>
<uc:UserPass ID="userPass1" runat="server"></uc:UserPass>
</Content>
</ext:Panel>
</Items>
</ext:Window>
</form>
</body>
</html>
UserPassword.ascx
<%# Control Language="C#" %>
<script runat="server">
public string UserName
{
get { return this.txtUser.Text; }
set { this.txtUser.Text = value; }
}
public string Password
{
get { return this.txtPassword.Text; }
set { this.txtPassword.Text = value; }
}
</script>
<ext:Panel ID="panel1" runat="server" BodyPadding="5" Layout="AnchorLayout">
<Items>
<ext:Panel ID="panel2" runat="server" Border="false" Header="false" AnchorHorizontal="100%" Layout="FormLayout">
<Items>
<ext:TextField ID="txtUser" runat="server" FieldLabel="User" />
<ext:TextField ID="txtPassword" runat="server" FieldLabel="Password" InputType="Password" />
</Items>
</ext:Panel>
</Items>
</ext:Panel>
Are there any known workarounds?
Short answer: Use this.txtPassword.setValue(value) not this.txtPassword.Text = value to fix your direct problem.
Long answer: Why you are setting the password from the server? Best practice states that passwords are stored as hashes on the server so you don't actually know a users real password, you are just comparing two hashes.
public string Password
{
get { return this.txtPassword.Text; }
set { this.txtPassword.Text = value; }
}
If you want to autofill a password, which i assume you do, you need to use a cookie.
if (Request.Cookies["username"] != null)
{
this.txtUsername.setValue(Request.Cookies["uid"].Value);
this.txtPassword.setValue(Request.Cookies["pwd"].Value);
}

Getting 404 error when trying to load Partial View into a View using MVC 5 and ASP.net 4.5

I have been working on this for a couple of weeks now. I’ve tried displaying my partial view into a view using many different methods (Html.Action, Html.Partial, Html.RenderAction & Html.RenderPartial). I’m getting a 404 error, which to me means that the ID is not getting passed into the controller action. This is just an assumption. The partial view I’m working with can be displayed directly by passing a URL parameter like so. https://siteurl.net/PersonalOffers/Snippet/2763795c-2d7b-462a-a7f6-ff966be83cfe I would like for the _Snippet Partial View to display in the Index page like so. https://siteurl.net/PersonalOffers/Index/2763795c-2d7b-462a-a7f6-ff966be83cfe I believe the answer lies in this post, but I can’t get the correct code combinations to work. How can I pass parameters to a partial view in mvc 4
What code should I use for the View? Here is the code I'm working with. Thanks!
ViewModel (SnippetViewModel.cs)
using SiteName.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace SiteName.Web.ViewModels
{
public class SnippetViewModel
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Terms { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
public string Image { get; set; }
public string QrImageCode { get; set; }
public string RedemptionLimit { get; set; }
public List<OfferLocation> OfferLocations { get; set; }
}
}
Partial View (_Snippet.cshtml)
#using Zen.Barcode;
#using Zen.Barcode.Web;
#using Zen.Barcode.Web.Mvc;
#model SiteName.Web.ViewModels.SnippetViewModel
<!doctype html>
<html lang="en">
<head>
<title>Offer Snippet</title>
#Styles.Render("~/Content/css")
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.centerPS {
margin: auto;
width: 20%;
padding: 5px;
}
</style>
</head>
<body>
<div id="content-wrapper" style="padding:5px; font-family: 'Times New Roman', Times, serif; font-size:22px;">
<div class="container">
<div class="page-header" style="text-align:center;"><h1><b>#Model.Name</b></h1></div>
<div class="well" style="text-align:center;">
<img src="#Model.Image" alt="Offer Image" /><br /><br />
<!-- Consumer Summary -->
<div class="row">
<div class="col-md-3 consumer-summary">
<div class="preloader-con">
<span><img src="~/Content/images/loader5.gif" /> Loading Consumer Details ...</span>
</div>
</div>
</div>
<div style="text-align:center; margin-bottom:20px; font-size:18px;"><div style="width:250px; display:inline-block;">#Model.Description</div></div>
<div style="text-align:center; margin-bottom:20px; font-size:18px;"><div style="width:250px; display:inline-block;">#Model.Terms</div></div>
<div style="text-align:center; margin-bottom:20px; font-size:18px;">
<div style="text-align:center;">Valid at:</div>
<div style="font-size: 14px; text-align:center;">
#foreach (var offerLocation in #Model.OfferLocations)
{
<p style="margin:0; padding:0;">#offerLocation.MerchantLocation.CompleteAddress</p><br />
<p style="margin:0; padding:0;">#offerLocation.MerchantLocation.Name</p>
}
</div>
</div>
<div style="clear:both; margin-bottom:20px;"></div>
<div style="text-align:center; font-size:18px;">
<div style="text-align:center;">
<div>Starts on: #Convert.ToDateTime(Model.StartDate).ToString("MM/dd/yyyy hh:mm tt")</div>
<div>Redeem by: #Convert.ToDateTime(Model.EndDate).ToString("MM/dd/yyyy hh:mm tt")</div>
<br />
<div>Redemption Limit: #Model.RedemptionLimit</div>
</div><br />
<div style="text-align:center;">
<img width="130" src="data:image/jpeg;base64,#Model.QrImageCode" />
</div>
</div>
<div style="clear:both; margin-bottom:20px;"></div>
<div style="text-align:center; margin-bottom:20px; font-size:20px;">#Model.Id</div>
<div style="text-align:center;"><h3>Mobile Wallet Pass</h3></div>
<!-- PassSlot widget -->
<div id="pslot-widget-container" class="centerPS" data-passtemplate="https://d.pslot.io/BqRFTzQ7M" data-show="true" data-zoom="50" data-placeholder-name="#Model.Name" data-placeholder-description="#Model.Description" data-placeholder-termsconditions="#Model.Terms" data-placeholder-expirydate="#Convert.ToDateTime(Model.EndDate).ToString("MM/dd/yyyy hh:mm tt")"></div>
<br />
<div style="text-align:center; margin-bottom:20px; font-size:20px;"><b>Powered by</b> <img src="~/Content/images/SiteName-blue.png" width="150" alt="SiteName Logo" style="margin-bottom: -6px;" /></div>
</div>
<!-- End Well -->
</div>
<!-- End Container -->
</div>
<!-- End Wrapper -->
<!-- PassSlot widget Java Script -->
<script id="pslot-wjs" src="https://www.passslot.com/public/passslot/pslot/widget/widget.js" type="text/javascript"></script>
<!-- Consumer Details Java Script -->
<script src="~/Scripts/SiteNameApp/consumer-details.js" type="text/javascript"></script>
</body>
</html>
Controller (PersonalOffersContoller.cs)
using SiteName.Infrastructure.Services;
using SiteName.Web.ViewModels;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Zen.Barcode;
using Zen.Barcode.Web;
using Zen.Barcode.Web.Mvc;
namespace SiteName.Web.Controllers
{
public class PersonalOffersController : Controller
{
private IOfferService _offerService;
private IOfferLocationService _offerLocationService;
private IUniqueOfferService _uniqueOfferService;
private IMerchantConsumerService _merchantConsumerService;
public PersonalOffersController(IOfferService offerService, IOfferLocationService offerLocationService, IUniqueOfferService uniqueOfferService, IMerchantConsumerService merchantConsumerService)
{
_offerService = offerService;
_offerLocationService = offerLocationService;
_uniqueOfferService = uniqueOfferService;
_merchantConsumerService = merchantConsumerService;
}
// Index view
public ActionResult Index(Guid id)
{
ViewData["id"] = id;
return View();
}
// GET: PublicOffers
public async Task<ActionResult> Snippet(Guid id)
{
var offer = await _offerService.FindAsync(id);
var offerLocations = await _offerLocationService.GetByOfferIdAsync(offer.Id);
var barcodeString = "https://sitename.net/PersonalOffers/Snippet/" + offer.Id.ToString();
CodeQrBarcodeDraw bd = BarcodeDrawFactory.CodeQr;
Image img = bd.Draw(barcodeString, 30, 3);
string limit = "";
if (offer.Limited && offer.RedemptionLimit != 0)
limit = offer.RedemptionLimit.ToString();
else
limit = "Unlimited";
SnippetViewModel model = new SnippetViewModel()
{
Id = offer.Id,
Name = offer.Name,
Description = offer.Description,
Terms = offer.TermsConditions,
OfferLocations = offerLocations.ToList(),
StartDate = offer.StartDate,
EndDate = offer.EndDate,
Image = "https://sitenamestorage.blob.core.windows.net/offers/thumb_" + offer.OfferImage,
RedemptionLimit = limit,
QrImageCode = this.getBase64Code(img)
};
return PartialView("_Snippet", model);
}
private string getBase64Code(Image img)
{
using (MemoryStream ms = new MemoryStream())
{
img.Save(ms, ImageFormat.Jpeg);
byte[] imageBytes = ms.ToArray();
string base64String = Convert.ToBase64String(imageBytes);
//string src = "data:image/jpeg;base64," + base64String;
return base64String;
}
}
}
}

Ext:net : Property grid bind it to store

is there anyway to bind propertgrid to the store.
I find a sample here ,is this the only way to bind data to propertgrid?I wanna bind data like as bind the gridview thank you
<script runat="server">
protected void Populate(object sender, DirectEventArgs e)
{
PropertyGridParameter p = new PropertyGridParameter();
p.Name = "dynamic";
p.Value = "property";
p.Editor.Add(new ComboBox());
this.PropertyGrid1.SetSource(new PropertyGridParameterCollection() { p }, true);
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:Button runat="server" Text="Populate" OnDirectClick="Populate" />
<ext:PropertyGrid ID="PropertyGrid1" runat="server">
<Source>
<ext:PropertyGridParameter Name="initial" Value="property" />
</Source>
</ext:PropertyGrid>
</form>
</body>
</html>
PropertyGrid internally uses its own store and its unavailable to bind data to in a similar way as you can do with a GridPanel.
I think nothing stops you to use a a common GridPanel if you have such a requirement.

Combo box listener in ext.net

I have an Ext.Net.ComboBox. It has been populated by using a sql query.
Now I need to filter the elements of the combo box based on the text entered.
For eg.
comboBox contains the following value.
Test1
Test2
MyTest
ComboTest
So when I enter the value 'Com' in the comboBox it should filter and display only ComboTest.
But if I enter Test then Test1, Test2 and ComboTest should be shown.
Please help me out. Thanks in Advance.
Edit : Refer this
Try the following based on this thread: http://forums.ext.net/showthread.php?16466-CLOSED-combobox-search-pattern
<%# Page Language="C#" %>
<%# Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.ComboBox1.GetStore();
store.DataSource = new object[]
{
new object[] { "1", "ab" },
new object[] { "2", "ac" },
new object[] { "3", "ba" },
new object[] { "4", "bc" },
new object[] { "5", "ca" },
new object[] { "6", "cb" }
};
store.DataBind();
}
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ext.Net Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:ComboBox
ID="ComboBox1"
runat="server"
MinChars="1"
Mode="Local">
<Store>
<ext:Store runat="server">
<Reader>
<ext:ArrayReader>
<Fields>
<ext:RecordField Name="value" />
<ext:RecordField Name="text" />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
</Store>
<Listeners>
<BeforeQuery Handler="var q = queryEvent.query;
queryEvent.query = new RegExp(q);
queryEvent.query.length = q.length;" />
</Listeners>
</ext:ComboBox>
</form>
</body>
</html>

Myfaces Trinidad JSF: Ajax problem when sending Non US-ASCII Characters

The Issue:
We have a Java web application, based on Apache MyFaces Trinidad. We are facing some problems when trying to partial submit (that's it: via Ajax) a form, when a field contains some special characters, such as Ñ, á, etc.
When we write a value like camión at the text field, the resulting message is Hola cami (it drops the special char, and the next one).
The application server we are runnign our code at is IBM WebSphere AS 7.0.
This behaviour has been observed on IExplorer and Firefox browsers, all run from Windows XP Professional (spanish version).
Main code snippets:
UPDATE: based on lkdg's answer (thanks), I have updated the JSP and resulting HTML code snippets.
JSP Page Code:
<%#page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%# taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%# taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%# taglib uri="http://myfaces.apache.org/trinidad" prefix="tr" %>
<%# taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh" %>
<f:view>
<tr:document>
<trh:head title="Prueba de AJAX con todas las Cabeceras">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</trh:head>
<tr:form>
<tr:panelHorizontalLayout halign="left">
<f:facet name="separator">
<tr:spacer width="10" height="5"/>
</f:facet>
<tr:inputText id="elCampo" label="Your name" value="#{commandButtonBean.name}"
requiredMessageDetail="Name is required"
/>
<tr:commandButton id="sayHello" text="Say Hello"
partialSubmit="true"
action="#{commandButtonBean.sayHello}"
/>
</tr:panelHorizontalLayout>
<tr:spacer height="15px"/>
<tr:outputText value="#{commandButtonBean.message}" partialTriggers="sayHello"
inlineStyle="font-weight: bold;"/>
</tr:form>
</tr:document>
</f:view>
This is the resulting HTML output (removed some empty lines):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--Start: org.apache.myfaces.trinidad.Document["j_id_jsp_1876237926_1"]--><html dir="ltr" lang="es-ES">
<head>
<meta name="generator" content="Apache MyFaces Trinidad">
<link rel="stylesheet" charset="UTF-8" type="text/css" href="/ModuloTrinidadPilotoWeb/adf/styles/cache/bigfont-desktop-nur72r-ltr-gecko.css">
</head>
<!--Start: org.apache.myfaces.trinidad.Document["j_id_jsp_1876237926_1"]-->
<body onload="_checkLoad()" onunload="_checkUnload(event)"><script type="text/javascript">var _AdfWindowOpenError='Se ha detectado un bloqueo de ventana emergente en el explorador. Estos bloqueos interfieren con el funcionamiento de esta aplicación. Desactívelo o permita elementos emergentes desde esta dirección.';</script><script type="text/javascript" src="/ModuloTrinidadPilotoWeb/adf/jsLibs/Common1_2_10.js"></script><!--Start: org.apache.myfaces.trinidad.Document["j_id_jsp_1876237926_1"]--><div id="tr_pprBlockingDiv" onclick="return _pprConsumeClick(event);" style="position:absolute;left:0;top:0;width:0;height:0;cursor:wait;" onkeydown="return false;" onkeyup="return false;" onmousedown="return false;" onmouseup="return false;" onkeypress="return false;"></div><a name="top"></a>
<noscript>Esta página utiliza JavaScript y necesita un explorador activado para JavaScript. Su explorador no está activado para JavaScript.</noscript>
<!--Start: org.apache.myfaces.trinidad.Head["j_id_jsp_1876237926_2"]-->
<head>
<title>Prueba de AJAX con todas las Cabeceras</title>
<meta name="generator" content="Apache MyFaces Trinidad">
<link rel="stylesheet" charset="UTF-8" type="text/css" href="/ModuloTrinidadPilotoWeb/adf/styles/cache/bigfont-desktop-nur72r-ltr-gecko.css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<!--Start: org.apache.myfaces.trinidad.Form["j_id_jsp_1876237926_3"]-->
<form id="j_id_jsp_1876237926_3" name="j_id_jsp_1876237926_3" style="margin:0px" method="POST" onkeypress="return _submitOnEnter(event,'j_id_jsp_1876237926_3');" action="/ModuloTrinidadPilotoWeb/jsp/sgtc/pruebaAjax2.faces"><!--Start: org.apache.myfaces.trinidad.Panel["j_id_jsp_1876237926_4"]--><table cellpadding="0" cellspacing="0" border="0" summary=""><tr>
<td><!--Start: org.apache.myfaces.trinidad.Input["elCampo"]--><table id="elCampo__xc_" class="af_inputText" cellpadding="0" cellspacing="0" border="0" summary=""><tr>
<td class="af_inputText_label" nowrap><span id="elCampo::icon" style="display:none;"><a name="_msgAnc_elCampo" title="Error" class="AFErrorIconStyle">X</a></span> <label for="elCampo">Your name</label></td>
<td valign="top" nowrap class="AFContentCell"><!--Start: org.apache.myfaces.trinidad.Input["elCampo"]--><input id="elCampo" name="elCampo" class="af_inputText_content" size="30" type="text"></td>
</tr><tr>
<td></td>
<td class="AFComponentMessageCell"><!--Start: org.apache.myfaces.trinidad.Input["elCampo"]--><span id="elCampo::msg" class="OraInlineErrorText"></span></td>
</tr></table></td>
<td><!--Start: org.apache.myfaces.trinidad.Object["j_id_jsp_1876237926_5"]--><img src="/ModuloTrinidadPilotoWeb/adf/images/t.gif" alt="" width="10" height="5"></td>
<td><script type="text/javascript">var _pprUpDatemode=false;function _adfspu(f,v,e,s,o){_pprUpdateMode=true;if(!o)o=new Object();if(e)o.event=e;if(s)o.source=s;_submitPartialChange(f,v,o);}</script><!--Start: org.apache.myfaces.trinidad.Command["sayHello"]-->
<button id="sayHello" name="sayHello" type="button" onclick="TrPage._autoSubmit('j_id_jsp_1876237926_3','sayHello',event,1);return false;" class="af_commandButton">Say Hello</button>
</td>
</tr></table><!--Start: org.apache.myfaces.trinidad.Object["j_id_jsp_1876237926_8"]--><div style="margin-top:15px"></div><!--Start: org.apache.myfaces.trinidad.Output["j_id_jsp_1876237926_9"]--><span id="j_id_jsp_1876237926_9" style="font-weight: bold;"></span><input type="hidden" name="org.apache.myfaces.trinidad.faces.FORM" value="j_id_jsp_1876237926_3"><!--Start: org.apache.myfaces.trinidad.Form--><span id="tr_j_id_jsp_1876237926_3_Postscript"><input type="hidden" name="javax.faces.ViewState" value="!-4fd3ee50"><script type="text/javascript">function _j_id_jsp_1876237926_3Validator(f,s){return _validateInline(f,s);}var j_id_jsp_1876237926_3_SF={};</script></span><script type="text/javascript">_submitFormCheck();</script></form>
</body>
<!--Created by Apache Trinidad (Apache MyFaces Trinidad API - 1.2.10/Apache MyFaces Trinidad Impl - 1.2.10), skin:bigfont.desktop (bigfont)--></html>
The CommandButton bean code:
public class CommandButtonBean {
public String name;
public String message;
public String sayHello(){
message = "Hola " + name;
return "";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
Of course, the command button is configured at faces-config.xml (I think that this snippet is not relevant).
Attempted fixes so far:
We have checked the charset encoding at different levels (application, JVM, etc). It seems to be aligned between the differen layers.
Also, we have included at web.xml the next context parameter:
<context-param>
<param-name>PARAMETER_ENCODING</param-name>
<param-value>UTF-8</param-value>
</context-param>
We have logged what is the value
passed as an argument to the
setName method, for if it could be
an error at writing the response. The
value passed is already wrong.
We have tried to write a web Filter,
to set the request charset to UTF-8 (just in
case, you know). But when logging the
parameter values at the filter, we
got the wrong value too.
At last we removed the
partialSubmit attribute of the
submit button, and got the right
value. But this won't really fix our
problem, as we are trying to
implement some inline searches and
validations (we don't want to repaint
the whole page).
So, when we send a normal POST message, we get the expected result, but when we try to use the Ajax approach, we loose these special characters.
And, at last, The Question:
Have you any suggestions on how to fix this issue?
Thank you very much.
This is a known issue with trinidad&WAS: http://www.mail-archive.com/dev#myfaces.apache.org/msg46298.html . You will have to make a small modification to two js files, you need to encode the sent characters (the solution there by Naveen Ravindra works). Edit these files:
trinidad-impl-XXX.jar\META-INF\adf\jsLibsDebug\xhr\XMLRequest.js
trinidad-impl-XXX.jar\META-INF\adf\jsLibs\xhr\XMLRequest.js
Add this new function to them (paste this to the beginning of the js:
function encodeCharacters(string) {
string = string.replace(/\r\n/g, "\n");
var utftext = "";
for ( var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
} else if ((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
}
Change the TrXMLRequest.prototype.send function in the same js. In it change
xmlhttp.send(content); to xmlhttp.send(encodeCharacters(content)); in the debug version, and
a4.send(a3); to a4.send(encodeCharacters(a3)); in the production version.
Tested, works in WAS 7.0.0.11.
Hi I can't reproduce your problem. Actually I don't get anything going if I try to program the jsp Page like you did. This is how my jsp's look like
<%# taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%# taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%# taglib uri="http://myfaces.apache.org/trinidad" prefix="tr" %>
<%# taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh" %>
<%# page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<f:view>
<tr:document>
<trh:head title="Your Title">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</trh:head>
</tr:document>
</f:view>
The tr:document, which you don't use creates a html, body and head tag.
You can use trh:head if you need it.
See trinidad's documentation:
Documentation tr:document
With this configuration I had no problem with an ó.
I have no PARAMETER_ENCODING set in web.xml and I am using jsf1.2 trinidad 1.2.14
This is not really an answer but it probably helps.
Regards
I've forgotten trinidad a bit, but in order for the button to affect the input text, dont you need a "partialTriggers" attribute set on the inputText component, which should have the ID of the button?
it is lkdg again
I tried to reproduce your issue.
jsp:
<tr:inputText
id="myfield"
value="#{myBean.myname}">
</tr:inputText>
<tr:commandButton
id="sayHello"
text="Say Hello"
partialSubmit="true"
action="#{myBean.sayHello}"/>
<tr:outputText
value="#{myBean.message}"
partialTriggers="sayHello"
inlineStyle="font-weight: bold;"/>
bean:
private String myname;
private String message;
public String sayHello()
{
message = "Hola " + myname;
return "";
}
public String getMyname() {
return myname;
}
public void setMyname(String myname) {
this.myname = myname;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
Everything works fine with ó and ễ and whatever.
jsf-1.2;trinidad1.2.14;apache tomcat6.0.29
I don't know the IBM WebSphere AS 7.0. But probably your problem has got something to do with what this guy is writing here: Displaying UTF-8 Characters in resource response

Resources