Finding message bundle from custom tag
I have a JSP page which has a <fmt:setBundle> to set the translations bundle. It also has a tag which I handle using a custom tag handler based on TagSupport. One of the attributes to this tag is a string which I need to look up in the message bundle, so I need to find the right message bundle as set at the top of the JSP page.
So putting the question succinctly, how, from custom tag handler code, do I find the message bundle the page is using?
So putting the question succinctly, how, from custom tag handler code, do I find the message bundle the page is using? To answer your question:
The <fmt:setBundle> tag (according to the documentation:
Creates an i18n localization context and stores it in the scoped variable or the
javax.servlet.jsp.jstl.fmt.localizationContext configuration variableSo you can look up that configuration variable, and use its information to obtain the resource bundle name, or the Localization object which wraps the bundle.
Of course, thats the hard way...
You see the friendly folks who wrote the JSTL knew that there would be people who would want to do this.
So they wrote a helper class for us: [javax.servlet.jsp.jstl.fmt.LocaleSupport|http://java.sun.com/products/jsp/jstl/1.1/docs/api/javax/servlet/jsp/jstl/fmt/LocaleSupport.html]
A better question is actually:
How do I look up a message in the bundle set by JSTL <fmt:setBundle> when I am in a custom tag handler?The answer is:
LocaleSupport.getLocalizedMessage(pageContext, key)Its all in their (relatively readable) [JSTL specification|http://java.sun.com/products/jsp/jstl/reference/api/index.html]
cheers,
evnafets
Similar Messages
-
Cannot find CFML template for custom tag
Why am I getting this error when my code looks like this?
Cannot find CFML template for custom tag UPSPrice.
ColdFusion attempted looking in the tree of installed custom tags but did not find a custom tag with this name. If you are using per-applica
<Cfif NOT form.shipzip IS "">
<CF_UPSPrice SERVICE="#form.upsshiptype#" FROM="#shopshipzip#" TO="#FORM.shipzip#" WEIGHT="#getshipweight.totwei#">
<cfelse>
<CF_UPSPrice SERVICE="#form.upsshiptype#" FROM="#shopshipzip#" TO="#FORM.zip#" WEIGHT="#getshipweight.totwei#">
</cfif>UPSPrice.cfm file:
<!---
NAME:
CF_UPSPrice
DESCRIPTION:
Cold Fusion custom tag obtain UPS shipping costs from ups.com.
ATTRIBUTES:
CALLTAG - (optional) Electronic or basic call tag issued, valid options
are NONE BASIC or ELECTRONIC, defaults to NONE.
COD - (optional) Package is being sent C.O.D., valid options are YES
and NO, defaults to NO.
FROM - (required) Source (ship from) postal code.
HANDLING - (optional) Requires special handling (eg. - any article that
is not fully encased in an outside shipping container,
or any package that exceeds 60 inches in length).
HAZARD - (optional) Package contains hazardous material, valid options are YES
and NO, defaults to NO.
HEIGHT - (optional) Height (in inches) of oversized package.
LENGTH - (optional) Length (in inches) of oversized package.
OVERSIZED - (optional) Package is oversized, valid options are YES and NO,
defaults to NO.
RESPONSE - (optional) Delivery confirmation service, valid options are
NONE BASIC SIGNATURE ALTERNATE or ALL, defaults to
NONE.
SATDELIV - (optional) Saturday delivery, valid options are YES and NO,
defaults to NO.
SATPICKUP - (optional) Saturday pickup, valid options are YES and NO,
defaults to NO.
SERVICE - (required) UPS Service ID, valid service IDs are:
1DM - Next Day Air Early AM
1DML - Next Day Air Early AM Letter
1DA - Next Day Air
1DAL - Next Day Air Letter
1DP - Next Day Air Saver
1DPL - Next Day Air Saver Letter
2DM - 2nd Day Air A.M.
2DA - 2nd Day Air
2DML - 2nd Day Air A.M. Letter
2DAL - 2nd Day Air Letter
3DS - 3 Day Select
GNDCOM - Ground Commercial
GNDRES - Ground Residential
SHIPNOT1 - (optional) First ship notification, valid options are NONE
DOMESTIC or INTERNATIONAL, defaults to NONE.
SHIPNOT2 - (optional) Second ship notification, valid options are NONE
DOMESTIC or INTERNATIONAL, defaults to NONE.
TOCOUNTRY - (optional) Destination country code, defaults to US if not
specified. Visit the UPS site for a complete list of
valid two letter country codes.
TO - (required) Destination (ship to) postal code.
VALUE - (optional) Declared value for carrier liability, carrier assumes
$100 by default.
VERBCONF - (optional) Verbal confirmation of delivery, valid options are YES
and NO, defaults to NO.
WEIGHT - (required) Weight (in pounds) of package, fractions may be used.
WIDTH - (optional) Width (in inches) of oversized package.
NOTES:
This tag submits a shipping cost request to UPS for processing, and returns
price and shipping information. CF_UPSPrice sets the following variables that
you may use within your template after the call to CF_UPSPrice:
UPS_BaseCharge - Base shipping charge.
UPS_Charge - Total charge.
UPS_Error - Error message, if there was one.
UPS_ErrorCode - Error code, if there was one.
UPS_FromCountry - Source country code.
UPS_FromPostal - Source postal code.
UPS_GuaranteedBy - Guranteed delivery time.
UPS_OptionalCharge - Total of optional charges.
UPS_Service - UPS service ID.
UPS_Success - YES if request was successful, NO if not.
UPS_ToCountry - Destination country code.
UPS_ToPostal - Destination postal code.
UPS_ToZone - Destination zone.
UPS_Weight - Billed weight.
USAGE:
To use just call <CF_UPSPrice> from within your Cold Fusion template,
passing at least the required attributes TO FROM SERVICE and WEIGHT.
EXAMPLES:
Obtain price for next day package from NY to CA:
<CF_UPSPrice SERVICE="1DA" FROM="11213" TO="90046" WEIGHT="1.5">
<CFOUTPUT>Cost is #DollarFormat(UPS_Charge)#</CFOUTPUT>
Sending a oversized package C.O.D. via second day air:
<CF_UPSPrice SERVICE="2DA" FROM="11213" TO="90046"
WEIGHT="1.5" HEIGHT="13" WIDTH="12" LENGTH="20" COD="Yes">
Using form fields:
<CF_UPSPrice SERVICE="#service#" FROM="#from#" TO="#to#" WEIGHT="#weight#">
AUTHOR:
Ben Forta ([email protected]) 10/14/97
With help from Dave Beckstrom ([email protected])
--->
<!--- Initialize variables --->
<CFSET proceed = "Yes">
<CFSET error_message = "">
<!--- Get UPS service --->
<CFIF proceed>
<CFIF IsDefined("ATTRIBUTES.service")>
<CFSET product = ATTRIBUTES.service>
<CFELSE>
<CFSET proceed = "No">
<CFSET error_message = "SERVICE must be specified!">
</CFIF>
</CFIF>
<!--- Get destination postal code --->
<CFIF proceed>
<CFIF IsDefined("ATTRIBUTES.to")>
<CFSET destPostal = ATTRIBUTES.to>
<CFELSE>
<CFSET proceed = "No">
<CFSET error_message = "TO postal code must be specified!">
</CFIF>
</CFIF>
<!--- Get source postal code --->
<CFIF proceed>
<CFIF IsDefined("ATTRIBUTES.from")>
<CFSET origPostal = ATTRIBUTES.from>
<CFELSE>
<CFSET proceed = "No">
<CFSET error_message = "FROM postal code must be specified!">
</CFIF>
</CFIF>
<!--- Get weight --->
<CFIF proceed>
<CFIF IsDefined("ATTRIBUTES.weight")>
<CFSET weight = ATTRIBUTES.weight>
<CFELSE>
<CFSET proceed = "No">
<CFSET error_message = "WEIGHT postal code must be specified!">
</CFIF>
</CFIF>
<!--- If all okay, process other options --->
<CFIF proceed>
<!--- Get destination country --->
<CFSET destCountry = "US">
<CFIF IsDefined("ATTRIBUTES.tocountry")>
<CFSET destCountry = ATTRIBUTES.tocountry>
</CFIF>
<!--- Get oversized --->
<CFSET oversized = "0">
<CFIF IsDefined("ATTRIBUTES.oversized")>
<CFIF ATTRIBUTES.oversized>
<CFSET oversized = "1">
</CFIF>
</CFIF>
<!--- Get COD --->
<CFSET cod = "0">
<CFIF IsDefined("ATTRIBUTES.cod")>
<CFIF ATTRIBUTES.cod>
<CFSET cod = "1">
</CFIF>
</CFIF>
<!--- Get hazard --->
<CFSET hazard = "0">
<CFIF IsDefined("ATTRIBUTES.hazard")>
<CFIF ATTRIBUTES.hazard>
<CFSET hazard = "1">
</CFIF>
</CFIF>
<!--- Get handling --->
<CFSET handling = "0">
<CFIF IsDefined("ATTRIBUTES.handling")>
<CFIF ATTRIBUTES.handling>
<CFSET handling = "1">
</CFIF>
</CFIF>
<!--- Get calltag --->
<CFSET calltag = "0">
<CFIF IsDefined("ATTRIBUTES.calltag")>
<CFIF ATTRIBUTES.calltag IS "BASIC">
<CFSET calltag = "1">
<CFELSEIF ATTRIBUTES.calltag IS "ELECTRONIC">
<CFSET calltag = "2">
</CFIF>
</CFIF>
<!--- Get Saturday delivery --->
<CFSET saturdaydelivery = "0">
<CFIF IsDefined("ATTRIBUTES.satdeliv")>
<CFIF ATTRIBUTES.satdeliv>
<CFSET saturdaydelivery = "1">
</CFIF>
</CFIF>
<!--- Get Saturday pickup --->
<CFSET saturdaypickup = "0">
<CFIF IsDefined("ATTRIBUTES.satpickup")>
<CFIF ATTRIBUTES.satpickup>
<CFSET saturdaypickup = "1">
</CFIF>
</CFIF>
<!--- Get response --->
<CFSET response = "0">
<CFIF IsDefined("ATTRIBUTES.response")>
<CFIF ATTRIBUTES.response IS "BASIC">
<CFSET response = "1">
<CFELSEIF ATTRIBUTES.response IS "SIGNATURE">
<CFSET response = "2">
<CFELSEIF ATTRIBUTES.response IS "ALTERNATE">
<CFSET response = "3">
<CFELSEIF ATTRIBUTES.response IS "ALL">
<CFSET response = "4">
</CFIF>
</CFIF>
<!--- Get vcd --->
<CFSET vcd = "0">
<CFIF IsDefined("ATTRIBUTES.verbconf")>
<CFIF ATTRIBUTES.verbconf>
<CFSET vcd = "1">
</CFIF>
</CFIF>
<!--- Get first ship notify --->
<CFSET firstshipnotify = "0">
<CFIF IsDefined("ATTRIBUTES.shipnot1")>
<CFIF ATTRIBUTES.shipnot1 IS "DOMESTIC">
<CFSET firstshipnotify = "1">
<CFELSEIF ATTRIBUTES.shipnot1 IS "INTERNATIONAL">
<CFSET firstshipnotify = "2">
</CFIF>
</CFIF>
<!--- Get second ship notify --->
<CFSET secondshipnotify = "0">
<CFIF IsDefined("ATTRIBUTES.shipnot2")>
<CFIF ATTRIBUTES.shipnot2 IS "DOMESTIC">
<CFSET secondshipnotify = "1">
<CFELSEIF ATTRIBUTES.shipnot2 IS "INTERNATIONAL">
<CFSET secondshipnotify = "2">
</CFIF>
</CFIF>
</CFIF> <!--- End process params --->
<!--- If have all params, process request --->
<CFIF proceed>
<CFHTTP
URL="http://www.ups.com/using/services/rave/qcostcgi.cgi"
METHOD="POST"
>
<CFHTTPPARAM TYPE="FORMFIELD" NAME="accept_UPS_license_agreement" VALUE="yes">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="10_action" VALUE="3">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="13_product" VALUE="#product#">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="15_origPostal" VALUE="#origPostal#">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="19_destPostal" VALUE="#destPostal#">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="22_destCountry" VALUE="#destCountry#">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="23_weight" VALUE="#weight#">
<CFIF IsDefined("ATTRIBUTES.value")><CFHTTPPARAM TYPE="FORMFIELD" NAME="24_value" VALUE="#ATTRIBUTES.value#"></CFIF>
<CFIF IsDefined("ATTRIBUTES.length")><CFHTTPPARAM TYPE="FORMFIELD" NAME="25_length" VALUE="#ATTRIBUTES.length#"></CFIF>
<CFIF IsDefined("ATTRIBUTES.width")><CFHTTPPARAM TYPE="FORMFIELD" NAME="26_width" VALUE="#ATTRIBUTES.width#"></CFIF>
<CFIF IsDefined("ATTRIBUTES.height")><CFHTTPPARAM TYPE="FORMFIELD" NAME="27_height" VALUE="#ATTRIBUTES.height#"></CFIF>
<CFHTTPPARAM TYPE="FORMFIELD" NAME="29_oversized" VALUE="#oversized#">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="30_cod" VALUE="#cod#">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="33_hazard" VALUE="#hazard#">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="34_handling" VALUE="#handling#">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="35_calltag" VALUE="#calltag#">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="37_saturdaydelivery" VALUE="#saturdaydelivery#">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="38_saturdaypickup" VALUE="#saturdaypickup#">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="39_response" VALUE="#response#">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="43_vcd" VALUE="#vcd#">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="44_firstshipnotify" VALUE="#firstshipnotify#">
<CFHTTPPARAM TYPE="FORMFIELD" NAME="45_secondshipnotify" VALUE="#firstshipnotify#">
</CFHTTP>
<!--- Check if succeeded --->
<CFIF ListFirst(CFHTTP.FileContent, "%") IS "UPSOnLine3">
<!--- Success, set variables --->
<CFSET CALLER.UPS_Success = "Yes">
<CFSET CALLER.UPS_Service = ListGetAt(CFHTTP.FileContent, 2, "%")>
<CFSET CALLER.UPS_FromPostal = ListGetAt(CFHTTP.FileContent, 3, "%")>
<CFSET CALLER.UPS_FromCountry = ListGetAt(CFHTTP.FileContent, 4, "%")>
<CFSET CALLER.UPS_ToPostal = ListGetAt(CFHTTP.FileContent, 5, "%")>
<CFSET CALLER.UPS_ToCountry = ListGetAt(CFHTTP.FileContent, 6, "%")>
<CFSET CALLER.UPS_ToZone = ListGetAt(CFHTTP.FileContent, 7, "%")>
<CFSET CALLER.UPS_Weight = ListGetAt(CFHTTP.FileContent, 8, "%")>
<CFSET CALLER.UPS_BaseCharge = ListGetAt(CFHTTP.FileContent, 9, "%")>
<CFSET CALLER.UPS_OptionalCharge = ListGetAt(CFHTTP.FileContent, 10, "%")>
<CFSET CALLER.UPS_Charge = ListGetAt(CFHTTP.FileContent, 11, "%")>
<CFSET CALLER.UPS_GuaranteedBy = ListGetAt(CFHTTP.FileContent, 12, "%")>
<CFSET CALLER.UPS_Error = "">
<CFSET CALLER.UPS_ErrorCode = "">
<CFELSE>
<!--- Failed, set variables and error message --->
<CFSET CALLER.UPS_Success = "No">
<CFSET CALLER.UPS_Service = "">
<CFSET CALLER.UPS_FromPostal = "">
<CFSET CALLER.UPS_FromCountry = "">
<CFSET CALLER.UPS_ToPostal = "">
<CFSET CALLER.UPS_ToCountry = "">
<CFSET CALLER.UPS_ToZone = "">
<CFSET CALLER.UPS_Weight = "">
<CFSET CALLER.UPS_BaseCharge = "">
<CFSET CALLER.UPS_OptionalCharge = "">
<CFSET CALLER.UPS_Charge = "">
<CFSET CALLER.UPS_GuaranteedBy = "">
<CFSET CALLER.UPS_Error = ListGetAt(CFHTTP.FileContent, 2, "%")>
<CFSET CALLER.UPS_ErrorCode = ListGetAt(CFHTTP.FileContent, 3, "%")>
</CFIF>
<CFELSE>
<!--- Failed, display error message, and abort --->
<CFOUTPUT><H1>Error: #error_message#</H1></CFOUTPUT>
<CFABORT>
</CFIF> -
Cannot find CFML template for custom tag SELECTDATE
Hi,
I am not a ColdFusion developer and just moved a site from one server to another. That site is developed by someone else not me and I just moved the site to ColdFusion server. Site is working fine except a few pages where I am getting this error:
Cannot find CFML template for custom tag SELECTDATE
I read a little bit about custom tags. These are files that needs to be placed in a certain folder from where ColdFusion reads them.
So that means I will need to ask the developer who developed this site to provide me with this custom tag file, which when I will place in appropriate folder, this page will start working? And without that file I cannot do anything about it?
ThanksAs Dan says, they're just CFM files. Usually one can identify them as follows:
* they're in the same directory as a file calling <cf_somefilename[...]>, wherein there is a somefilename.cfm is the name of the file
* they're in one of the directories set as custom tag directories (in CFAdmin, or Application.cfc)
* they have references to "thistag" or the attributes scope in them (although the latter can produce false positives on Fusebox sites)
By the sounds of it, your issue is - like I said before - you haven't got your custom tag dirs set up in CFAdmin (or in Application.cfc, which I didn't mention before). Investigate that.
Adam -
How to access Message bundle from beans??
Greetings i am new to JSF.
I want to access my message bundle from beans, anyone could tell me how to do it?
Also, i need my beans to obtain the url address of my servlet automatically, how can i do that?
Thanks for any help!Another alternative if using the <f:loadBundle> tag within your JSP is to do something like the following in your bean logic:
In a JSP:
<f:loadBundle basename="Resources" var="messages"/>
In Bean:
ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext();
// Obtains the Map containing the key/value pairs loaded by the loadBundle tag
Map messages = (Map) extContext.getRequestMap().get("messages");
As to the second question, I'm assuming you want the URL that invoked the current request? If so, look at ExternalContext.getRequestPathInfo() and ExternalContext.getRequestServletPath(). -
Writing Cookie from Custom Tag
Hi Everyone.
I am attempting to write a cookie from a custom tag with the following code.
private void writeCookie(){
Cookie cookie = new Cookie("TEST", "cookie_value_from_tag");
cookie.setMaxAge(60*60*24*7* 52);
cookie.setComment("Test_CookieFromCuttomTag");
cookie.setPath("/student");
javax.servlet.http.HttpServletResponse resp = (javax.servlet.http.HttpServletResponse)pageContext.getResponse();
System.out.println("Adding test cookie from CustomTag");
resp.addCookie(cookie);
System.out.println("DONE Adding test cookie from CustomTag");
}The cookie never appears on my machine.
I see the messages that wrap the resp.addCookie() method
so I know the code is being called.
What am I doing Wrong?
My Browser is set to accept ALL cookies.
I am using Tomcat 4.1.27
Any and all help is greatly appreciated
SeanActually, the cookie is not writing when I am using <jsp:include>
It works fine when I do not use include
the jsp I am using to include is
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:registration="urn:jsptld:/WEB-INF/enrollment.tld"
xmlns:html="urn:jsptld:/WEB-INF/struts-html.tld"
xmlns:logic="urn:jsptld:/WEB-INF/struts-logic.tld"
xmlns:bean="urn:jsptld:/WEB-INF/struts-bean.tld"
xmlns:common="urn:jsptld:/WEB-INF/common.tld"
version="2.0" >
<jsp:directive.page language="java" contentType="text/html;charset=UTF-8"/>
<html xmlns:jsp="http://java.sun.com/JSP/Page">
<body>
<jsp:include flush="true" page="forgotPasswordChallenge.jsp"/>
<jsp:include flush="true" page="new_forgotPassword.jsp"/>
<common:validation_message/>
</body>
</html>
</jsp:root>the custom tag is <common:validation_message/>
Any Ideas on why this is occuring? -
IsUserInRole() - return boolean from custom tag?
Hello
Im writing some custom tags extending TagSupport. At the moment my tags just create some collection and put it in the page scope for the jsp to access. (see example below)
I have a tag however that I would like to return a boolean for. This is specifically for checking isUserInRole();
I cant quite get my head around the idea of manipulating the page body or not and how this impacts writing the custom tags. If I want to return some value directly from my tag ie. a boolean value from isUserInRole(); is this manipulating the page body?
Is TagSupport the correct class to extend if I want to return a boolean value from my tag call.
Id appreciate any advice.
Thanks
Jon
public class refSuppliersTag extends TagSupport {
public int doStartTag() throws JspException {
try {
HashMap supplierMap = new HashMap();
supplierMap = (HashMap) referenceData.getSuppliers();
pageContext.setAttribute("suppliers", supplierMap);
} catch (Exception e) {
throw new JspException(e.toString());
return EVAL_PAGE;
------------------------------------------this is one way of designing your tag:
In JSTL
<my:login var="isAdminRole" role="admin"/>
<!-- test for it -->
<c:if test="${isAdminRole}">
yeah, you are admin user!
</c:if>
In Java
boolean isLoggedin = login();
session.setAttribute(var,isLoggedin);
// where "var" is a String tag attribute!
//...put the "boolean" result in "var", which is a session's parameter, request's parameter or whatever!
by Avatar Ng
[blog http://avatar21.superihost.com/ ]
Message was edited by:
Avatar_Ng -
Passing Values back from Custom Tag
I'm using custom tags, and I'm trying to pass back values to the JSP page from a tag which is iterating over values it gets from an Array. But for some reason I can't access the values.
Here is the Tag:
public class MemberHelper extends TagSupport implements IterationTag {
private Iterator iterator;
protected Tag parent;
protected PageContext pageContext;
public MemberHelper() {
super();
public void otherDoStartTagOperations() {
sfmember_prop_desc desc = new sfmember_prop_desc();
ArrayList allt = new ArrayList();
try {
allt = desc.GetAllCustom();
} catch (java.sql.SQLException ex) {}
if(allt.size() > 0)
iterator = allt.iterator();public void otherDoEndTagOperations() {
public boolean shouldEvaluateRestOfPageAfterEndTag() {
return true;
public int doStartTag() throws JspException, JspException {
otherDoStartTagOperations();
if (theBodyShouldBeEvaluated()) {
return EVAL_BODY_INCLUDE;
} else {
return SKIP_BODY;
public int doEndTag() throws JspException, JspException {
otherDoEndTagOperations();
if (shouldEvaluateRestOfPageAfterEndTag()) {
return EVAL_PAGE;
} else {
return SKIP_PAGE;
public int doAfterBody() throws JspException {
if (theBodyShouldBeEvaluatedAgain()) {
return EVAL_BODY_AGAIN;
} else {
return SKIP_BODY; -
Trying to get AuthenticationUser from custom tag
Hello, I'm trying to access the authentication username from a custom tag. The code we're using is this:
IPTSession session = (IPTSession)GetEnvironment().GetUserSession();
String authName = session.GetUser().GetAuthenticationUser();
But we get an exception:
com.plumtree.server.marshalers.PTException: -2147024891 - Error in function PTUser.GetAuthenticationUser (): -2147024891 - PLUMTREE authentication in use. AuthUser is user name.
What does this mean? Does anyone know how else to approach this?Are you trying to get login name or definition of the user present in user repository ?
Check these methods: GetUniqueAuthName() or GetLoginName(). -
How to find broken url from custom 404 page?
I have created a custom 404 jsp page and updated the web deployment descriptor with the code:
<error-page>
<error-code>404</error-code>
<location>/jsp/custom-404.jsp</location>
</error-page>Whenever I enter an invalid url or click on broken link (target does not exist), a 404 HTTP response arises and the custom-404.jsp is rendered. So far so good.
Within the custom-404.jsp, I would like to know the original url (invalid link or broken link) so that I can send the administrator an email with the url details.But, I could not find any API to find this url?
Can someone help here please?
ThanksMy bet is that it is available as referrer inside the error page in case of a redirect, or as Request URI in case of a forward.
String referrer = httpServletRequest.getHeader("referer"); // Yes, with the legendary misspelling in it.
// or
String requestURI = httpServletRequest.getRequestURI(); -
Wsdl validation fails for request message payload from custom schema
Hello. I am having a problem which I cannot seem to work around. I have defined a schema to serve as a template for the request message payload of a bpel process. The schema is very simple:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:logininfo="http://sru/logininfo" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sru="http://sru/profile" targetNamespace="http://sru/logininfo" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://sru/profile" schemaLocation="http://sru/profile.xsd"/>
<xs:element name="logininfo" type="logininfo:logininfoType">
<xs:annotation>
<xs:documentation>Needed information for SRU Login</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="logininfoType">
<xs:all>
<xs:element name="email" type="sru:emailType"/>
<xs:element name="password">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="32"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="product" type="xs:string"/>
<xs:element name="ip" type="sru:ipType"/>
<xs:element name="timestamp" type="xs:dateTime"/>
<xs:element name="xpath" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:schema>
(The schema depends on another, which I have placed at the end of this message).
I import it into the bpel process designer with no problems.
Upon defining the payload of the request message type to be the {http://sru/logininfo}logininfoType, the WSDL file does not validate anymore:
Validating WSDL...
Validating E:\OraBPELPM_1\integration\jdev\jdev\mywork\SRU\BPELProcess5\BPELProcess5.wsdl
Schema type not found: QName(http://sru/logininfo, logininfoType)
Validate WSDL: has errors.
Any ideas?
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://sru/profile" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sru="http://sru" xmlns:xdb="http://xmlns.oracle.com/xdb" targetNamespace="http://sru/profile" elementFormDefault="qualified" attributeFormDefault="unqualified" xdb:schemaURL="http://sru/profile.xsd">
<xs:annotation>
<xs:documentation>Joel Salmerón Viver</xs:documentation>
<xs:documentation xml:lang="en">General purpose internet profile schema</xs:documentation>
</xs:annotation>
<xs:simpleType name="emailType">
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
<xs:pattern value="[a-z0-9]([a-z0-9\._][a-z0-9]+)*@[a-z0-9]([a-z0-9\.\-][a-z0-9]+)*\.[a-z]{2,6}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ipType">
<xs:restriction base="xs:string">
<xs:pattern value="((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="labelType">
<xs:restriction base="xs:string">
<xs:maxLength value="32"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="addressType" xdb:SQLType="ADDRESSTYPE" xdb:SQLSchema="SRU">
<xs:all>
<xs:element name="lines" type="linesType" minOccurs="0" xdb:SQLName="lines" xdb:SQLType="LINESTYPE" xdb:SQLSchema="SRU" xdb:SQLInline="true">
<xs:key name="linesKey">
<xs:selector xpath="line"/>
<xs:field xpath="@num"/>
</xs:key>
</xs:element>
<xs:element name="city" xdb:SQLName="city" xdb:SQLType="VARCHAR2" xdb:SQLInline="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="64"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="postalcode" xdb:SQLName="postalcode" xdb:SQLType="VARCHAR2" xdb:SQLInline="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="16"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="countrycode" xdb:SQLName="countrycode" xdb:SQLType="VARCHAR2" xdb:SQLInline="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:all>
<xs:attribute name="label" type="labelType" use="required" xdb:SQLName="label" xdb:SQLType="VARCHAR2"/>
<xs:attribute name="verified" type="xs:boolean" use="required" xdb:SQLName="verified" xdb:SQLType="RAW"/>
</xs:complexType>
<xs:complexType name="lineType" xdb:SQLType="LINETYPE" xdb:SQLSchema="SRU">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="num" type="xs:positiveInteger" use="required" xdb:SQLName="num" xdb:SQLType="NUMBER"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="loginType" xdb:SQLType="LOGINTYPE" xdb:SQLSchema="SRU">
<xs:all>
<xs:element name="registered_date" type="xs:dateTime" xdb:SQLType="TIMESTAMP WITH TIME ZONE" xdb:SQLName="registered_date" xdb:SQLInline="true"/>
<xs:element name="lastlogin_date" type="xs:dateTime" xdb:SQLType="TIMESTAMP WITH TIME ZONE" xdb:SQLName="lastlogin_date" xdb:SQLInline="true"/>
<xs:element name="lastlogin_ip" type="ipType" minOccurs="0" xdb:SQLName="lastlogin_ip" xdb:SQLType="VARCHAR2" xdb:SQLInline="true"/>
<xs:element name="lastlogin_time" type="xs:time" minOccurs="0" xdb:SQLType="TIMESTAMP WITH TIME ZONE" xdb:SQLName="lastlogin_time" xdb:SQLInline="true"/>
</xs:all>
<xs:attribute name="product" use="required" xdb:SQLName="product" xdb:SQLType="VARCHAR2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="32"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="status" type="xs:integer" use="required" xdb:SQLName="status" xdb:SQLType="NUMBER"/>
</xs:complexType>
<xs:complexType name="addressesType" xdb:SQLType="ADDRESSESTYPE" xdb:SQLSchema="SRU">
<xs:sequence>
<xs:element name="address" maxOccurs="unbounded" xdb:defaultTable="PROFILE_ADDRESSES" xdb:SQLName="address" xdb:SQLSchema="SRU" xdb:SQLInline="true" xdb:defaultTableSchema="SRU" xdb:SQLCollType="address360_COLL" xdb:SQLCollSchema="SRU" xdb:maintainOrder="false">
<xs:complexType xdb:SQLType="address358_T" xdb:SQLSchema="SRU">
<xs:complexContent>
<xs:extension base="addressType"/>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="main" type="labelType" use="required" xdb:SQLName="main" xdb:SQLType="VARCHAR2"/>
</xs:complexType>
<xs:complexType name="phonesType" xdb:SQLType="PHONESTYPE" xdb:SQLSchema="SRU">
<xs:sequence>
<xs:element name="phone" type="phoneType" maxOccurs="unbounded" xdb:SQLName="phone" xdb:SQLType="PHONETYPE" xdb:SQLSchema="SRU" xdb:SQLInline="true" xdb:SQLCollType="phone363_COLL" xdb:SQLCollSchema="SRU" xdb:maintainOrder="false"/>
</xs:sequence>
<xs:attribute name="main" type="labelType" use="required" xdb:SQLName="main" xdb:SQLType="VARCHAR2"/>
</xs:complexType>
<xs:complexType name="loginsType" xdb:SQLType="LOGINSTYPE" xdb:SQLSchema="SRU">
<xs:sequence>
<xs:element name="login" type="loginType" maxOccurs="unbounded" xdb:SQLName="login" xdb:SQLType="LOGINTYPE" xdb:SQLSchema="SRU" xdb:SQLInline="true" xdb:SQLCollType="login366_COLL" xdb:SQLCollSchema="SRU" xdb:maintainOrder="false">
<xs:key name="loginKey">
<xs:selector xpath="."/>
<xs:field xpath="@product"/>
</xs:key>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="phoneType" xdb:SQLType="PHONETYPE" xdb:SQLSchema="SRU">
<xs:simpleContent>
<xs:extension base="phonenumberType"/>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="profileType" xdb:SQLType="PROFILETYPE" xdb:SQLSchema="SRU">
<xs:all>
<xs:element name="firstname" xdb:SQLName="firstname" xdb:SQLType="VARCHAR2" xdb:SQLInline="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="64"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="surname1" xdb:SQLName="surname1" xdb:SQLType="VARCHAR2" xdb:SQLInline="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="64"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="surname2" minOccurs="0" xdb:SQLName="surname2" xdb:SQLType="VARCHAR2" xdb:SQLInline="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="64"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="gender">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="1"/>
<xs:enumeration value="M"/>
<xs:enumeration value="F"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="alt_email" type="emailType" minOccurs="0" xdb:SQLName="alt_email" xdb:SQLType="VARCHAR2" xdb:SQLInline="true"/>
<xs:element name="addresses" type="addressesType" minOccurs="0" xdb:SQLName="addresses" xdb:SQLType="ADDRESSESTYPE" xdb:SQLSchema="SRU" xdb:SQLInline="true">
<xs:key name="addressesKey">
<xs:selector xpath="address"/>
<xs:field xpath="@label"/>
</xs:key>
<xs:keyref name="addressRef" refer="addressesKey">
<xs:selector xpath="."/>
<xs:field xpath="@main"/>
</xs:keyref>
</xs:element>
<xs:element name="phones" type="phonesType" minOccurs="0" xdb:SQLName="phones" xdb:SQLType="PHONESTYPE" xdb:SQLSchema="SRU" xdb:SQLInline="true">
<xs:key name="phoneKey">
<xs:selector xpath="phone"/>
<xs:field xpath="@label"/>
</xs:key>
<xs:keyref name="phoneRef" refer="phoneKey">
<xs:selector xpath="."/>
<xs:field xpath="@main"/>
</xs:keyref>
</xs:element>
<xs:element name="language" type="xs:language" xdb:SQLName="language" xdb:SQLType="VARCHAR2" xdb:SQLInline="true"/>
<xs:element name="logins" type="loginsType" minOccurs="0" xdb:SQLName="logins" xdb:SQLType="LOGINSTYPE" xdb:SQLSchema="SRU" xdb:SQLInline="true">
<xs:key name="loginsKey">
<xs:selector xpath="login"/>
<xs:field xpath="@product"/>
</xs:key>
</xs:element>
<xs:element name="origin" minOccurs="0" xdb:SQLName="origin" xdb:SQLType="VARCHAR2" xdb:SQLInline="true">
<xs:annotation>
<xs:documentation>iso3166 a2 country code</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="creation_date" type="xs:dateTime" xdb:SQLType="TIMESTAMP WITH TIME ZONE" xdb:SQLName="creation_date" xdb:SQLInline="true"/>
<xs:element name="modified_date" type="xs:dateTime" xdb:SQLType="TIMESTAMP WITH TIME ZONE" xdb:SQLName="modified_date" xdb:SQLInline="true"/>
<xs:element name="password" xdb:SQLName="password" xdb:SQLType="VARCHAR2" xdb:SQLInline="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="32"/>
<xs:pattern value="[a-zA-Z0-9]+"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="hint" minOccurs="0" xdb:SQLName="hint" xdb:SQLType="VARCHAR2" xdb:SQLInline="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="32"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="additional" type="xs:anyType" minOccurs="0">
<xs:annotation>
<xs:documentation>future expansion</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:attribute name="email" type="emailType" use="required" xdb:SQLName="email" xdb:SQLType="VARCHAR2"/>
<xs:attribute name="active" type="xs:boolean" use="required"/>
</xs:complexType>
<xs:complexType name="phonenumberType" xdb:SQLType="PHONENUMBERTYPE" xdb:SQLSchema="SRU">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="label" type="labelType" use="required" xdb:SQLName="label" xdb:SQLType="VARCHAR2"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:element name="profile" type="profileType" xdb:defaultTable="PROFILES" xdb:SQLName="profile" xdb:SQLType="PROFILETYPE" xdb:SQLSchema="SRU" xdb:defaultTableSchema="SRU"/>
<xs:complexType name="linesType" xdb:SQLType="LINESTYPE" xdb:SQLSchema="SRU">
<xs:sequence>
<xs:element name="line" type="lineType" maxOccurs="unbounded" xdb:SQLName="line" xdb:SQLType="LINETYPE" xdb:SQLSchema="SRU" xdb:SQLInline="true" xdb:SQLCollType="line354_COLL" xdb:SQLCollSchema="SRU" xdb:maintainOrder="false"/>
</xs:sequence>
</xs:complexType>
</xs:schema>IT would help if the people that are working this issue would post the resolve of their problems. Every post I see with this problem someone from oracle replies with needing the source project to replicate the issue and the thread dies....
-
Message bundles accessed from JSF and JSP pages
Hello, everybody!
I'm developing a localized JSF application. It is working pretty well until now.
These are my message files:
mensagens.properties
mensagens_en_US.propertiesThis is how they're configured in faces-config.xml:
<application>
<resource-bundle>
<base-name>br.urca.www.biblioteca.web.mensagens</base-name>
<var>msg</var>
</resource-bundle>
</application>And this is how I access the messages in a page:
<h:outputText value="#{msg.titulo}" />Nothing new until now. But now there was a need for me to have a raw jsp page in
my web application. This page is displaying ok but I also need to access the
message bundles as I'm able to access in the normal jsp with the JSF components.
As you should know I can't use something like the above code with an +<h:outputText>+
to access the messages because this is a JSF component and I'll not be able to use
JSF components with this raw jsp page.
So, my question is: how do I access my localized messages from a raw jsp page? I
suppose there should be a way to do this, but unfortunately I started programming
to the web world in Java with JSF, not JSP, so I don't know how to do this with
JSP.
Thank you very much.
MarcosBalusC wrote:
Just include [jstl-1.2.jar|https://maven-repository.dev.java.net/repository/jstl/jars/] in your classpath and define the fmt taglib in your JSP. Nothing more is needed.
Hello, BalusC. Thank you for your help. We're almost there. After I have included the jstl-1.2.jar you provided me I can use the fmt tag and access message bundles from my raw jsp page (even though I had to provide other message bundles instead of the ones that I use in the other jsf pages, but it's better than nothing).
Now there just on problem to be fixed. The jsp page is not aware when I change the locale of my application. I change this locale in a jsf page.
I have this component:
<h:selectOneMenu value="#{pesquisaAcervo.idiomaAplicacao}"
valueChangeListener="# {pesquisaAcervo.idiomaAplicacaoMudado}" onchange="submit();">
<f:selectItems value="#{pesquisaAcervo.idiomasAplicacao}" />
</h:selectOneMenu>that calls this event in my backing bean class:
public void idiomaAplicacaoMudado(ValueChangeEvent e)
fIdiomaAplicacao.liberarItens();
Idioma idioma = Idioma.deString(e.getNewValue().toString());
// This line is for JSF
FacesContext.getCurrentInstance().getViewRoot().setLocale(idioma.localidade());
// This line is for Tiles
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().
put(org.apache.tiles.locale.impl.DefaultLocaleResolver.LOCALE_KEY, idioma.localidade());
}So, do I have to include another line in the idiomaAplicacaoMudado event above in order for the jsp page load the correct resource bundle? Or what else do I have to do?
Thank you.
Marcos -
Custom Tag issue and then ApplicationID?
Hello,
is there anybody out there who can help me with the following
problem:
I installed ColdFusion 4.5 Server on my Windows XP machine
and wanted to access an already built CF application. When
accessing
the main default page, i got the following error:
"Cannot find CFML template for custom tag
CFA_APPLICATIONINITIALIZE.
ColdFusion attempted looking in the tree of installed custom
tags but
did not find a custom tag with this name. "
I copied the same Administrator settings, code and folders
from the
working production server to my local machine and it just
doesn't seem
to work. (I couldn't find any differences to the working
application)
I tried to fix it by copying the custom tag folder (located
under allaire/spectra/customtags/) to C:\CFusion\CustomTags which
somehow cleared the previous error but gave me the following new
one:
"Error Occurred While Processing Request > Error
Diagnostic Information > This application can't be located by
name. Use ApplicationID instead"
Please, i appreciate any kind of comment on this post (i have
been trying to fix this for the past 3 days!)
Thanks,
bbintoSpectra requires 4.5.1 or 5.
Run the Spectra install to set up all the correct mappings
and the webtop. Then copy over the custom application. It's been
awhile since I've dug into the folder structure of the webtop, so I
don't have a complete list of steps required for a Spectra app
deployment. So you still have some work ahead of you.
Just make sure you backup your database before the install,
mirror it, or use a new schema for the installation and then switch
over your datasources.
I would recommend an old Spectra book you can probably find
on eBay.
http://www.forta.com/books/0789723654/ -
Customize Db Constraint Error (Custom Msg bundle vs Custom Trans FrameWork)
Dear all,
As in ADF 4GL Guide : ch. 25.8.3 & 25.8.4, Customizing Database Constraint Error can be done, either by using:
- Custom Message Bundles
OR
- Custom Transaction Class
In the examples there, it is still not clear what is the benefit of using Custom Transaction Class while using Custom Message Bundles seems to be simpler.
So, actually how can the second option be better compared to the first one ?
Than you for your help,
xtantoxtanto,
I agree with your assesment - custom message bundles is much simpler for this use case. If you wanted to do something more "fancy" with the error handling, you would use the custom DBTransactionImpl class. This paragraph from the guide sums it up, I guess:
If the default facility for assigning a custom message to a database constraint violation
does not meet your needs, you can implement your own custom constraint error
handling routine.
I haven't run into a situation where I've needed to use the DBTransactionImpl approach.
Best,
John -
I am part of a team that admins 3 Windows 2003 web servers
running ColdFusion MX7. Each of the 3 servers has the
CFX_Excel2Query custom tag registered. The tag works without issue
on our production and development, but not on the test server. On
the test server, we receive the message, "The CFX custom tag
"CFX_excel2query" was nt found in the custom tag database. Please
be sure ...."
Additional info:
I registered the tag in the "CFX Tags" Page
I registered the location of the CFX_Excel2Query to the
"Custom Tag Paths" page
Any help would be greatly appreciated.
Thanks,
TonyQuestions:
1. Have you tried the CFSPREADSHEET tag?
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec17cba-7f 87.html
2. Can you post your code? -
F:loadBundle and message-bundle difference
Hello I have one question:
I have those lines in my faces-cofig:
<locale-config>
<default-locale>pl_PL</default-locale>
<supported-locale>en_US</supported-locale>
</locale-config>
<message-bundle>pl.myCompany.crm.localization.application</message-bundle>
and this line is in every jsp file that use messages properties:
<f:loadBundle basename="pl.myCompany.crm.localization.application" var="messages" />
my questin is:
Is there a possiblity to define only <message-bundle> in faces-config.xml and use properties in jsp files without defining f:loadBundle.
I know that I can remove the message-bundle from faces-config .xml and everything works fine but in that case I have path to my resources file in almost evry jsp file in my app and this path could be changed in the future.
Regards
TomAnother question : how can I get the current Locale
of the session context ?UIViewRoot#getLocale()
Resource bundle is stored as a request scope variable of Map type.
Maybe you are looking for
-
Transforming perspective of smart objects
I am trying to bring a poster that I've made in Illustrator into a photoshop image(a storefront). I am pasting the .ai file as a smart object so that in the future, I can swap in other posters that are made in AI. I also will need to distort the pers
-
example here: http://www.cupsannual.ca/ the example shows that some of the graphic wont start playing until you scroll and only when visible to the scroll level(not sure about the right term for that) thank you in advance!
-
Can I un-share certain items in my iTunes music library?
Hi all, I am allowing music library sharing at work. But there are a couple items in my library that I don't want to share with folks. Is there a way to keep them in my library and turn them "off" so to speak? Thanks.
-
Stock using 2LIS_03_BX and 2LIS_03_BF
Hi all, We have initilaised 2LIS_03_BX on 9th mar 2006. And then we have loaded historical stock data from 1st apr 2004 till 9th mar 2006 ie. around two years into stock cube. But the R/3 system has data since it is started i.e from 2000. I have doub
-
Careful with the install, lost almost everything.
I was having so many problems with Leopard I decided to re-install. I tried an archive twice but the installer hung up. I did an upgrade. Some of my apps are gone, it seemed to like Adobe stuff so that's here, but just about everything else was wiped