Using a heirachical key name in bean:message

This is sort of an odd requirement but it will help me out greatly if I can find a way to do this.
I am working on creating a JSP which generates vxml. I am using a resource properties file to read in text that I need to speak, or the names of wave files that I need to play. I grab these using a bean:message tag lib call. This all works fine but now I need to extend this app to handle several different States (Kentucky, Ohio, etc) which may or may not have small variations in their verbiage.
Tell me if I am going about this entirely wrong but this is what I think would be nice to do:
I would like to use the name of the key in this form:
"prompt.company.state"
Where an example resource properties file might be like this:
mainmenu.columbia.ky=mainmenu_ky.wav
mainmenu.columbia=MM_Columbia.wav
mainmenu=mainmenu.wavWhat I would like to happen is if I request the key "mainmenu.columbia.ky" it returns the "mainmenu_ky.wav", but if I request "mainmenu.columbia.oh" it would return "MM_Columbia.wav"
The idea is that a company may operate in different states and customize its prompts for that state if custom prompts exist but if they do not exist it uses the default for that company. Also there could be different company names also so if I asked for "mainmenu.northface" I would receive "mainmenu.wav"
This is sort of like localization but I want to have all the keys in one file.
My thought is that I would need to create my own taglib that extends bean:message and then parses the key name accordingly until I find a matching key. My problem is I have no idea where to start when doing that. I am while I have a strong Java background its been almost 4 years since I've worked on a project using it, and all this Struts and JSP and JSTL stuff is quite new to me.
Does anyone have any tips for me? Maybe there is another tag lib out there which does exactly what I need and I just don't see it. Help anyone?

This is sort of an odd requirement but it will help me out greatly if I can find a way to do this.
I am working on creating a JSP which generates vxml. I am using a resource properties file to read in text that I need to speak, or the names of wave files that I need to play. I grab these using a bean:message tag lib call. This all works fine but now I need to extend this app to handle several different States (Kentucky, Ohio, etc) which may or may not have small variations in their verbiage.
Tell me if I am going about this entirely wrong but this is what I think would be nice to do:
I would like to use the name of the key in this form:
"prompt.company.state"
Where an example resource properties file might be like this:
mainmenu.columbia.ky=mainmenu_ky.wav
mainmenu.columbia=MM_Columbia.wav
mainmenu=mainmenu.wavWhat I would like to happen is if I request the key "mainmenu.columbia.ky" it returns the "mainmenu_ky.wav", but if I request "mainmenu.columbia.oh" it would return "MM_Columbia.wav"
The idea is that a company may operate in different states and customize its prompts for that state if custom prompts exist but if they do not exist it uses the default for that company. Also there could be different company names also so if I asked for "mainmenu.northface" I would receive "mainmenu.wav"
This is sort of like localization but I want to have all the keys in one file.
My thought is that I would need to create my own taglib that extends bean:message and then parses the key name accordingly until I find a matching key. My problem is I have no idea where to start when doing that. I am while I have a strong Java background its been almost 4 years since I've worked on a project using it, and all this Struts and JSP and JSTL stuff is quite new to me.
Does anyone have any tips for me? Maybe there is another tag lib out there which does exactly what I need and I just don't see it. Help anyone?

Similar Messages

  • Use initialization file key names/values as cluster name/values

    I am trying to assign my initialization key name and values to a clusters names/values repestively.  For example, I read in the ini file key names (dir, user, year) and would like those to be the cluster labels and then read in the associated values and assign them to the cluster.
    For example, if my ini file is:
    [Sample]
    dir=c:
    user=jnoel
    year=1971
    I would like the cluster element names to be dir,user, and year with the values for each being c:, jnoel, and 1971 respectively.  I tried using the property node for label:text but Labview states the labels are not allowed to be changed in runtime.  I would think there would be some way to do this (and if not there should be!). 
    Any help would be greatly appreicated.

    MikeS81 wrote:
    Ben wrote:
    Hide the cluster names and show the captions.
    Captions can be written at run time.
    Ben
    Sorry,
    that´s what i´ve meant.
    Mike
    No it is me that should say "Sorry". Before my coffee had kicked in I had not realized that the description = caption.
    I was sorta wondering why you hadn not suggested captions, "doh!"
    Well between the two of us we got it right.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Can you change iMessage to not use the enter key to send a message on a macbook pro?

    I'm using a mac with OS X Yosemite version 10.10.1 and I'm wondering if you can somehow change the settings of iMessage so that when you press the enter key it doesn't send the message. Thanks if you can help.

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • Using EL variable in struts bean:message tag(not struts EL tag)

    Is there any work around to use an EL variable inside struts bean:message tag as key:
    I have like this:
    <bean:message key="${bean.keyName}"/>
    which is throwing error , I know this can be resolved by using struts-el tags but i cannot use them for specific reasons.
    I dont want to use bean:define tag to define my 'bean' and then use like this:
    <bean:message key="<%=bean.getKeyName%>"/> (this actually works, but i want to use EL variable)
    Is there any work around to use EL variable and make the message display on the jsp.
    i tried multiple ways like scriplets and jsp:useBean but nothing worked, Please let me know..
    Thanks in advance

    Im pretty sure that EL does not work in the normal struts tag unless its struts-el tag.Have you tried it?
    As I said, in a properly configured JSP2.0 container you can use EL expressions anywhere you could traditionally use a standard runtime expression <%= expr %>.
    What server are you using? What JSP version?
    The Struts-el tags were written so that you could use EL with struts in JSP1.2 containers.
    The c_rt tags were written so you could use runtime expressions with JSTL tags in JSP1.2 containers. Their use was discouraged even then. Now I consider their use absolutely unnecessary.
    Please read this thread: http://forum.java.sun.com/thread.jspa?threadID=629437&tstart=0
    Cheers,
    evnafets

  • Dynamic key in bean:message

    hi,
    i would like to use a <bean:message> in my page but with a dynamic key:
    <logic:iterate id="vSendMode" name="SvGetCommandRavelForm" property="recSendModeList">
    <bean:message key="sendMode.agence${vSendMode.idSmod} .modeead${vSendMode.idAgency}" />
    </logic:iterate>
    only it tells me that the key sendMode.agence${vSendMode.idSmod} .modeead${vSendMode.idAgency} doesn't exist. which is true but for example sendMode.agence0 .modeead0 exists...
    how can i do that ?
    thanks :-)

    Yes you can use runtime expressions with the bean:message tag.
    However your container has to recognise the ${expr} as a runtime expression.
    1 - You need a JSP2.0 container (eg Tomcat 5)
    2 - your web.xml file needs to declare itself as version 2.4
    ie:<?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        version="2.4">
    ...If you just put ${vSendMod.idSmod} on the page does it print the appropriate value?
    If EL is working, then try this:
    <c:set var="myKey" value="sendMode.agence${vSendMode.idSmod} .modeead${vSendMode.idAgency}" />
    <bean:message key="${myKey}"/>
    If you only have a JSP1.2 container, take a look at the struts-el taglib, or use a <%= expr %> instead of EL.
    Cheers,
    evnafets

  • How can I restore Thunderbird behavior so I can delete emails by pressing delete key multiple times (without using mouse to change focus back to message list)?

    Thunderbird 24.3.0 (latest under OpenBSD)
    I (like most people) get spam in my inbox. When there are multiple spam messages in a row in my inbox I used to click on the first message and then press the delete key repeatedly for each sequential spam message.
    After upgrading, this doesn't work. Instead, when I click a message it opens in the message preview pane and moves the focus to the message. Thus I need to click twice to even be able to press the delete key to delete one message. When I press the delete key, the message is deleted and the highlighted message becomes the next one in the list. This opens the message in the preview pane and again shifts the focus to the message. Thus I can't press the delete key again but must move the mouse to click on the message before I can delete it.
    As a result, what used to be a very fast process of weeding through spam has become a real annoyance.
    I realize I can hide the message preview pane to prevent the focus from moving, but this means I must delete solely based on the email subject/sender -- or open each message (which is even slower).
    I also realize that I can press tab multiple times (sometime 4, sometimes many more) to shift the focus back but that's not much faster than using the mouse.
    How can I prevent Thunderbird from shifting the focus away from the email list panel unless I actually click somewhere else?

    Well said! And you said it about six weeks ago. And 4 other people said "Me Too." - I guess we're screwed.
    I guess it's time to switch to GMail.
    Such a trivial thing, but it irritates me every single time.
    MOZILLA - YOU'RE GOING DOWNHILL...

  • Unable to publish in Swf format. Get error message: 'Swf compilation failed. Note: Please verify if any of the actionscript keywords is used as user variable name'. Anyone know how to fix?

    Unable to publish in Swf format. Get error message reads: 'Swf compilation failed. Note: Please verify if any of the actionscript keywords is used as user variable name'. Anyone know how to fix?

    Hi There,
    Can you tell me the Operating System and Captivate version you are using?
    Also can you confirm if you are getting this issue will this one project or all the projects? Try to copy paste this project on a new blank project and then try to publish.
    Regards,
    Mayank

  • When adding bookmarks and trying to changing its name, Firefox won't allow using the mouse; Firefox will only allow using the arrow keys (MAC OS 10.5, Firefox 3.6.8)

    When adding a bookmark sometimes the web page name is too long. I used to be able to use my mouse, highlight the letters/words that I don't want, then use delete to truncate the desired bookmark name. Since the latest update/upgrade, Firefox won't let me use the mouse to click anywhere in the popup box. I can only use the arrow keys and the delete key.
    Nothing other than updates (using Mac Software Update and Firefox Update) has been done to this computer (it's a 2002 Power Mac G4-Dual 1.25GHz).

    When adding a bookmark sometimes the web page name is too long. I used to be able to use my mouse, highlight the letters/words that I don't want, then use delete to truncate the desired bookmark name. Since the latest update/upgrade, Firefox won't let me use the mouse to click anywhere in the popup box. I can only use the arrow keys and the delete key.
    Nothing other than updates (using Mac Software Update and Firefox Update) has been done to this computer (it's a 2002 Power Mac G4-Dual 1.25GHz).

  • When publishing a captivate I get the message "Swf compilation failed. Note: Please verify if any of the actionscript keywords is used as user variable name." and it won't allow me to publish the Captivate, can anyone help?

    When publishing a captivate I get the message "Swf compilation failed. Note: Please verify if any of the actionscript keywords is used as user variable name." and it won't allow me to publish the Captivate, can anyone help?

    Hi There,
    Can you tell me the Operating System and Captivate version you are using?
    Also can you confirm if you are getting this issue will this one project or all the projects? Try to copy paste this project on a new blank project and then try to publish.
    Regards,
    Mayank

  • When I use the Alt key and the clone tool, I get a message that I did not use the Alt key to define

    Whe I use the Alt key with the clone tool, I get a message that I have to use the Alt key to define the area to be copied. What am I doing wrong?

    I tried to check the alined box, but it would not work. I was able to check
    the Sample box, but they they give you about 5 choices to check and I have
    no  idea what they are all about. I appreciate your help.
    Dino
    In a message dated 9/18/2012 11:09:06 A.M. Eastern Daylight Time, 
    [email protected] writes:
    Re:  When I use the Alt key and the clone tool, I get a message that I did 
    not use the Alt key to define
    created by hatstead (http://forums.adobe.com/people/hatstead)  in 
    Photoshop Elements - View the full  discussion
    (http://forums.adobe.com/message/4707426#4707426)

  • HT1379 I am trying to reset NV/RAM PRAM and am instructed to use the option key. I cant find an option key on my keyboard. Does it have another name?

    I am trying to reset NV/RAM PRAM on Apple website and I am instructed to use the options key. There is no options key on my 2008 keyboard. Does it now have another name?

    Step by Step to fix your Mac

  • Always use the default account when composing new messages box missing in Outlook 2010 after updating the product key.

    I have 2 accounts in outlook 2010. 1 is for me and the other I have delegate access to. When I am in the delegates email and want to reply it automatically uses the account the email is in. So if I am in my email, the from is me but if I am in the delegates
    email and hit reply the from is them. Now this is not working and I can't figure out how to get it to work. The only thing that changes is that office asked me to activate recently, which is weird since I have had this same computer with the same version of
    office for almost a year now. I did a ton of searching and came across an option on the internet: "Always use the deafult account when composing new messages" but this option is not there on my computer. I checked another computer I have with Office
    2010 also and the option is available so it must be something to do with the office activation because I haven't done it on this computer yet. PLEASE HELP!!!

    Seems this is a hot issue recently, I've post a reply to another thread with the similar topic, please reference that:
    http://social.technet.microsoft.com/Forums/en-US/57289ddd-0dd5-4938-92f7-ee420d8b0d7c/outlook-2010-does-not-reply-to-emails-using-the-same-address-that-received-it?forum=officeitproprevious
    Thanks for your updating.
    Tony Chen
    TechNet Community Support

  • bean:message/ tag is not working in tiles:insertAttribute/

    I have a bean:message tag inside my tiles:insertAttribute as shown below.
    <tiles:insertAttribute name='<bean:message="user.menu"/>'/>But <bean:message/> is not getting the value from resource bundle, my resource bundle is in correct place. If i hard code the value then it s working fine.
    How to make it work? Any help?

    sunish_jose wrote:
    <tiles:insertAttribute><bean:message="user.menu"/></tiles:insertAttribute>this way it s not working. Could you pls tell how solve it by using EL. I was not able to find a similar sample evenafter searching for some time.
    thanks in advance.I did say that I don't know if it will or not, I was just giving a sample of how it would work if the tag allowed the value for 'name' to be put in the body.
    I'm not very familiar with the Struts bean tags and in any case, I believe you should use the JSTL tags where ever possible. So you'd pick the <fmt:message> tag from there. I don't think the <bean:message> tag allows you to get the value in to a variable.
    <fmt:message var="tilesAttributeNameValue" key="user.menu" />
    //create an EL variable named tilesAttributeNameValue with the value from the resource bundle
    <tiles:insertAttribute name="${tilesAttributeNameValue}"></tiles:insertAttribute>
    //use EL to put the valueTake a look here [1] for a JSTL introduction:
    [1] http://www.ibm.com/developerworks/java/library/j-jstl0415/

  • Error on bean:message and resource properties file ??

    Hi everyone! I'm new to struts and i just can't figure out why tomcat's giving me an error. I've manage to run a simple example but when i use the bean:message tag i get this error
    ERROR IS:
    java.lang.NullPointerException
         org.apache.struts.taglib.TagUtils.retrieveMessageResources(TagUtils.java:1175)
         org.apache.struts.taglib.TagUtils.message(TagUtils.java:1038)
         org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:224)
         org.apache.jsp.index_jsp._jspx_meth_bean_message_0(org.apache.jsp.index_jsp:135)
         org.apache.jsp.index_jsp._jspx_meth_html_html_0(org.apache.jsp.index_jsp:101)
         org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:69)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Can anyone help me with this problem?
    my ApplicationResources.propeties file is in WEB-INF/classes
    index.jsp
    <%@ page language="java" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <html:html locale="true">
    <head>
        <title> <bean:message key="index.title"/> </title>
    </head>
    <body>
    <html:link module="/exercise" action="/welcome">Taglib Test Pages</html:link>
    </body>
    </html:html>
    web.xml
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
      "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>
      <!-- Action Servlet Configuration -->
      <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <!-- Resources bundle base class -->
        <init-param>
          <param-name>application</param-name>
          <param-value>ApplicationResources</param-value>
        </init-param>
          <!-- Context-relative path to the XML resource containing Struts configuration information -->
        <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <!-- The debugging detail level for this servlet, which controls how much information is logged. -->
        <init-param>
         <param-name>debug</param-name>
         <param-value>2</param-value>
        </init-param>
        <init-param>
         <param-name>detail</param-name>
         <param-value>2</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <!-- Action Servlet Mapping -->
      <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>
    <!-- The Welcome File List -->
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      <!-- Struts Tag Library Descriptors -->
      <taglib>
        <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
      </taglib>
      <!-- Application Tag Library Descriptor -->
      <taglib>
        <taglib-uri>/WEB-INF/app.tld</taglib-uri>
        <taglib-location>/WEB-INF/app.tld</taglib-location>
      </taglib>
    </web-app>Please help..thanks in advance

    I have that on my struts-config.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE struts-config PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
              "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
    <struts-config>
      <form-beans>
    </form-beans>
      <global-forwards>
      </global-forwards>
      <action-mappings>
      </action-mappings>
      <message-resources parameter="ApplicationResources"/>
    </struts-config>and I also include it on my web.xml file
    <!-- Resources bundle base class -->
        <init-param>
          <param-name>application</param-name>
          <param-value>ApplicationResources</param-value>
        </init-param>

  • Struts tag bean:message in jsp

    Hi
    I used
    <bean:message key="inputform.username" property="username"/>
    in my jsp page to access value using this key from resource bundle.
    While requesting the page the error is showing that----
    javax.servlet.ServletException: Missing message for key "inputform.username"
    Please help me in this problem
    Thanks in advance
    Sudheesh

    I've tried with <bean:write... but since I catch exception saying MyActionForm can't be found in any scope. As far as I'm aware I've set request scope like:
    <action input="/jsp/something.jsp" name="MyActionForm" path="/jsp/myAction" scope="request" type="sth.MyAction">
    <forward name="success" path="/jsp/index.jsp"/>
    <forward name="failure" path="/jsp/something.jsp"/>
    </action>
    Edited by: D.A.R. on Sep 26, 2007 12:09 PM

Maybe you are looking for

  • How to display TEXT more than 500 char in a report as multiple lines.

    Hi Friends, i have a requirement like i should display Texts of length more than 500 Characters in a report( ALV LIST) as multiple lines I am fetching the data Using FM READ_TEXT the output im currently geeting with 150 Char in lenth as a single line

  • SLD - Logical System Management

    Hi, We are implementing XI and we have the problem with SLD logical system management. The problem is that we use the same Logical system name (Ex. PRDclnt350) for all the systems to avoid running lengthy BDLS process when we hook our R3 systems to t

  • DskPercent not returned for ZFS filesystems?

    Hello. I'm trying to monitor the space usage of some ZFS filesystems on a Solaris 10 10/08 (137137-09) Sparc system with SNMP. I'm using the Systems Management Agent (SMA) agent. To monitor the stuff, I added the following to /etc/sma/snmp/snmpd.conf

  • All browsers freeze in Mavericks

    Ever since i've moved from Mountain Lion to Mavericks i'm having major problems with all browsers (Safari, Chrome, Firefox, Chromium). They all freeze for 4-5 seconds, and this happens every 1-2 minutes. This happens on every pages i visit, even on '

  • Installing Oracle 10.2 on Windows 7

    Hi all, I'm tryinmg to install the above but cannot get past the initial operating system check. Details below. It says to install the correct service pack...IS that for Windows or Oracle? I need to stick to 10.2 as the rest of the team are using tha