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

Similar Messages

  • 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?

  • Storing bean:message value

    I want to be able to utilize a request.getParameter value to make the key attribute for the bean:message to be dynamic. I have parts of my application urls in the ApplicationProperties.properties and I want a parameter to dynamically tell bean:message which key to use. Then once bean:message pulls back that data, I want to store it into a field to use in an jsp:include. Can this be done?
    I pretty much would like to do the following if it was legal syntax:
    <jsp:include flush="true" page="bean:message key="<%= request.getParameter(pageType) %>""/>

    It is possible if u use JSTL-RT tag not the JSTL-EL tag. Please check
    http://java.sun.com/webservices/docs/1.0/tutorial/doc/JSTL.html
    http://java.sun.com/webservices/docs/1.0/tutorial/doc/JSTL5.html#65106
    Hope u got it.
    Hafizur Rahman
    SCJP

  • 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>

  • 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

  • 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

  • bean:message in JSP

    Hi
    i used
    <bean:message key="inputform.username" property="username">
    in my jsp to access the value using key from a resource bundle=--
    While executing the error is showing that
    javax.servlet.jsp.JspException: Missing message for key "inputform.username"
    But i given this application.properties..
    Please Help me
    Regards
    Sudheesh

    java.lang.NullPointerException
    at
    weblogic.ejb20.internal.EJBRuntimeUtils.throwRemoteExc
    eption(EJBRuntimeUtils.java:103)-- Error : In
    companyRoleAddAction.doRoleAdd():Why don't you check the line where this piece of code is generating null pointer :)
    Regards,
    $ Carol.

  • Struts bean:message encoding help

    Hello, i am using Struts framework and have problems with resource files.
    I have two files for english and lithuanian.
    jsp file:
    <%@ page contentType="text/html; charset=Cp1257" pageEncoding="Cp1257"%>
    Developed by: <bean:message key="developer.name"/>
    So its echo bad string.
    Any ideas?

    I have had same problem but I have resolve it by both changing the encoding property of IDE(mine is NetBeans 3.6) to UTF-8 and
    put the line
    <%@page pageEncoding="UTF-8"  contentType="text/html; charset=UTF-8" %>on the top of jsp pages.
    But now I having some problems with formbean I hope I resolve it.
    You can follow it from here
    http://forum.java.sun.com/thread.jspa?threadID=698855

  • Bean:message tag

    hi
    sup i wanna use bean:message tag for the image file which is definrd in properties file
    <img align="top" src="/assets/images/common/buttons/bt_bl_continue_v1_en.gif" border="0" style="vertical-align:top; _vertical-align:middle;"></a>
    like
    <bean:message key="com.something.continue_img">
    then how shud i provide the formatting to it like style etc

    All you need do is put the <bean:message> tag as the src attribute.
    In the message bundle the message is the file name to load.
    <img align="top" src="<bean:message key="com.something.continue_img">
    " border="0" style="vertical-align:top; _vertical-align:middle;"></a>

  • FI-SD integration issue Error in account determination: table T030K key NECA EXD Message no. FF709

    Dear expert.
    Thank you for adding me at your professinal network Linkedin. I am getting some issue related to FI-SD integration.
    IT's coming while releasing billing document in Tcode VF02.
    Error in account determination: table T030K key XXXX EXD
    Message no. FF709
    I look into Tcode VKOA- Acct determination for Cust Grp Mat Grp for sales organization for EXD, OB40 - EXD AcctKey, V/08- checked procedure Zneac.
    And also maintained the taxcode in Vk11.
    But i am not able to understand the issue.
    Please  reply with valuable suggestion.
    Thanks in advance.
    Regards Mani.
    manibhushanchoubey8 at the rate gmail dot com

    Hi
    Please check below links
    Error in account determination:T030K
    Msg no.FF709 Error in account determination: table T030K key INT VS1 I0
    Note: Please search in the forum before posting the issue
    Thanks
    Dasaradha

  • Message Driven bean: message always removed from queue

    We use MDB to dequeue messages from database queue (AQ) and want to handle errors: if the transaction rolls back, message should have retry_count updated and after defined retries should move to exception queue.
    The problem is, that with all combinations of transactions settings, the message is removed from queue before onMessage is called. If I use Container managed transactions with Mandatory transaction attribute, call to setRollbackOnly fails with message "java.lang.IllegalStateException: Cannot call setRollbackOnly() current thread is NOT associated with a transaction."
    How can I write a MDB, which can commit or rollback message depending on whether exception is or is not thrown? I use JDev 10.1.3.
    Thanks,
    Viliam
    Here are my files:
    ejb-jar.xml:
    <?xml version = '1.0' encoding = 'windows-1250'?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
      <enterprise-beans>
        <message-driven>
          <description>Message Driven Bean</description>
          <display-name>SendSMSBean</display-name>
          <ejb-name>SendSMSBean</ejb-name>
          <ejb-class>sk.transacty.cc.ejb.SendSMSBeanBean</ejb-class>
          <transaction-type>Container</transaction-type>
          <acknowledge-mode>Auto-acknowledge</acknowledge-mode>
          <message-driven-destination>
            <destination-type>javax.jms.Queue</destination-type>
          </message-driven-destination>
          <resource-ref>
            <res-ref-name>jdbc/CCDataSource</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
          </resource-ref>
        </message-driven>
      </enterprise-beans>
      <assembly-descriptor>
        <container-transaction>
          <method>
            <ejb-name>SendSMSBean</ejb-name>
            <method-name>*</method-name>
          </method>
          <trans-attribute>Mandatory</trans-attribute>
        </container-transaction>
      </assembly-descriptor>
    </ejb-jar>orion-ejb-jar.xml:
    <?xml version = '1.0' encoding = 'windows-1250'?>
    <!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans 1.1 runtime//EN" "http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd">
    <orion-ejb-jar>
      <enterprise-beans>
        <message-driven-deployment max-instances="1" name="SendSMSBean" connection-factory-location="java:comp/resource/jmsAQ/QueueConnectionFactories/aqQue" destination-location="java:comp/resource/jmsAQ/Queues/msg_queue" listener-threads="1" min-instances="0"/>
      </enterprise-beans>
      <assembly-descriptor>
        <default-method-access>
          <security-role-mapping impliesAll="true" name="<default-ejb-caller-role>"/>
        </default-method-access>
      </assembly-descriptor>
    </orion-ejb-jar>

    As far as I know XMLType JMS messages are not supported when using OJMS. They might be for OC4J 10.1.3, but I thought it's an AQ limitation rather than an OC4J one.. To be sure you might just log a TAR on Metalink.
    hth,
    Bastiaan

  • READ statement with dynamic key

    Can i READ a dynamic table with a dynamic key combination?
    READ TABLE <dyn_sel_table>
      INTO       <dyn_sel_wa>
      WITH KEY   ? .

    yes i guess u can do it
    READ TABLE <dyn_sel_table>
    <b>ASSIGNING</b> <dyn_sel_wa>
    WITH KEY <field1> eq ...

  • EAP-TLS, how is dynamic key transmitted?

    how is the dynamic key derived and transmitted?

    You may want to look into section 3.5 and 3.8 of RFC 2716. There is also a seciton on this in the following link:
    http://www.cisco.com/warp/public/cc/pd/sqsw/sq/tech/acstl_wp.htm

  • Error in account determination: table T030K key 1000 BED Message no. FF709

    Hi,
    the following is error i am getting
    Error in account determination: table T030K key 1000 BED
    Message no. FF709
    I have maintained the account assignment of cmr mmr in vkoa combinations
    and also in ob40 maintained tax codes for bed account key
    but now am unable to release billing doc
    please help me

    Hi
    Please check below links
    Error in account determination:T030K
    Msg no.FF709 Error in account determination: table T030K key INT VS1 I0
    Note: Please search in the forum before posting the issue
    Thanks
    Dasaradha

Maybe you are looking for