Struts nesting the bean:write tag

hi I want to nest the <bean:write tag into any other html tag
i.e.
<html:hidden property="color" value="<bean:write name="colorSet" property="colorValue" />"/>
Could you tell me if I am missing any quotes or something ?
Thanks

You can't use custom tags as attributes to other tags.
The correct way to do this in struts would be to populate the action form as part of the action.

Similar Messages

  • Struts.  Using bean:write to access actionForm parameters

    While I am not new to web applications, I am fairly new to Struts.
    What I am trying to accomplish is to have a read only view of a maintenance form.
    Instead of using html:input fields to display the values in a form bean, I want to use the bean:write tag to just display their values.
    However the bean:write tag requires the "name" field, specifying which bean to display a property from.
    I am thinking of grabbing the bean from request scope (org.apache.struts.taglib.html.BEAN) and using that, but are there any better ways to accomplish what I want?
    Or is what I am attempting breaking the rules in some way, and I should desist immediately?
    cheers,
    evnafets

    I am thinking of grabbing the bean from request scope.thats fine. u r not breaking any rules.
    U can set the form bean on the page wtih <c:set> tag. This way u can use the name everywhere in that page.
    but are there any better ways to accomplish what I want?ofcourse there are different ways to achieve ur goal.
    I think of it more as a convenience issue.
    since u r not modifying the form and its attr's u could specify the scope of the form as session in the struct-config.xml and in the jsp provide the form name in the <form> tag. This way ur jsp will automatically get the relevant form bean from the session scope and u will not need the name attribute.
    sien...

  • How can I useStruts bean:write tag with parameter

    Helow i'm using Struts tags for reading data from beans
    for example:
    public String getUserName(){
    return name;
    in the jsp:
    <bean:write name="userInfoBean" property="userName"/>
    but i have a getter with paramer as this:
    public String getUserName(String id){
    return getNameById(id);
    How can i write the tag in the jsp???

    You can't directly.
    Your method MUST have the signature public String getUserName() in order to be identified as an attribute of the bean, accessed via the bean:write tag.
    One workaround is to set the "id" as a separate property, and then use that attribute in the getUserName method.
    ie
    int id;
    public void setUserId(int newId){
      this.id = newId;
    public String getUserName(){
      return getUserName(id);
    }

  • Getting  error in using bean:write   tag

    hi ,
    in my logon.jsp i m putting
    these 2 lines
    <bean:write name="logonForm" property= "username"/>
    <html:errors/>
    i m getting error "cannot find logonForm in scope null"
    then i added scope ="request" in bean tag
    i got error "cannot find logonForm in scope null"
    my motive is to display what ever the the value user has entered as user name in logon.jsp
    ..is it possible by use of this tag ..
    plz help me in this case.
    thanks in advance.

    sorry
    after adding scope="request" i got error "cannot find logonForm in scope request"
    but
    <bean:write name="logonForm" property="username" scope="request"/>
    this tag is working fine when i placed it in jsp that is getting fwded by logon page
    thanks

  • Struts - filter in bean:write

    Hi
    On my page in html:textarea i write something like this:
    line 1
    line 2
    line 3<br>line 4and on my other side i use <bean:write name="f6Form" property="w1" filter="true" />
    and i get:
    line 1 line 2 line 3<br>line 4and i need to get:
    line 1
    line 2
    line 3<br>line 4How do this using bean:write (or filter only) and don't change w1 value

    You want do display preformatted text? Use HTML <pre> tag or set CSS white-space property of parent HTML element to 'pre'.

  • Struts bean/html tag problem

    i am writing this url_element on screen
    <bean:write name="url_element"/>
    then i got a link
    <html:link action="urlDetail.do?url=???">aaa</html:link>
    how can i transfer the url_element into ??? do i need to write something like <%...%>?

    just found the solution:
    You can't use a <bean:write> tag inside an <html:link> tag. Struts doesn't support it.
    The easiest way to fix this is to abandon use of <html:link> and just use the plain old html tags <a></a>. Then you will have no problem substituting parameters with <bean:write> tags.
    The only advantage <html:link> has over the plain html tag is that it automatically does URL rewriting (Adding of the jsessionid to the URL so that sessions may be tracked even if the user has turned cookies off). If you're not using this function anyway, as most modern websites don't, you may as well use the html tag.
    If you still want to use <html:link>, use the struts-el version of the html tags and use EL expressions instead of <bean:write> tags.

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

  • Bean:write and complex types

    I have a Java object like that:
    public class OBJ1 {
    String name;
    String id;
    OBJ2 [] Array_OBJ2;
    // getters and setters methods for name,id and Array_OBJ2
    OBJ2 is an an object like this:
    public class OBJ2 {
    String surname;
    OBJ3 [] Array_OBJ3;
    // getters and setters methods for surname and Array_OBJ3
    And OBJ3 is like this:
    public class OBJ3 {
    String control;
    // getters and setters methods for control
    I passed a OBJ1 object to a jsp page and I can access to "name" and "id" properties successfully, but I have problems to access to the "Array_OBJ2" object.
    What's the correct syntax in the jsp page to access it in a bean:write tag ?

    Hi
    I am not sure just thinking and guessing try this.......
    <logic:iterate name="OBJ1" id="item" property="Array_OBJ2">
        <bean:write name="item" />
    </logic:iterate>do reply wheather it works or not

  • How to use bean:write inside jsp:include ?

    I got a problem about JSP's syntax. The following is my code:
    <%@ include file="<bean:write name="HelloForm" property="target" />"%>
    The double quotes inside bean:write is my problem. Could you please teach me how to use bean:write within JSP's include? Thank you!

    http://java.sun.com/products/jsp/syntax/1.2/syntaxref12.html
    Include Directive vs <jsp:include>
    The include directive <%@include %> is done at page translation/compile time.
    It effectively pastes in a static file, and then compiles the JSP as if it was all one file.
    As such, you cannot provide a runtime expression to it.
    To do runtime inclusion, you need to use the <jsp:include> tag which does except runtime parameters.
    <%String test = request.getParameter("pageInfo");%>
    <%String link = test + ".jsp"; %>
    <jsp:include page="<%= link %>" %>Unfortunately you can't use the tag with a bean:write tag as well, you can only use runtime expressions, not tag. So you have to do the include with
    <jsp:include page="<%= HelloForm.getTarget() %>" />
    Cheers,
    evnafets

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

  • How to use bean write in  struts html:text tag

    hi,
    i'm new to struts concepts.here i'm trying to write a value in html struts tag using <bean:write>
    my current tag is
    <html:text property="empname" value='<bean:write name="employee" property="empid">' />
    but it gives same tag in the text box.how i can solve this.

    what am I doing wrong?You will notice above that I mentioned
    YOU CAN'T USE CUSTOM TAGS AS ATTRIBUTES TO OTHER CUSTOM TAGS
    (was that loud enough for you to notice this time)?
    Try
    <html:text styleId="instruction" styleClass="text" size="50" name="instruction" property="value"/>
    //or
    <html:text styleId="instruction" styleClass="text" size="50" property="instruction" value="<%= instruction.getValue() %>"/>
    better alternative: populate your formbean with your action and just have:
    <html:text styleId="instruction" styleClass="text" size="50" property="instruction"/>
    If you set the "instruction" property of your formBean in the action, the value will be automagically reflected here.
    Cheers,
    evnafets

  • Looking for struts bean:write   Equivalent function/ tag in jsf??

    Hi to all,
    I am quite new to jsf. Soi might be asking a stupid question.
    I just wanna to know is there an equivalent tag or simple scriplet that can provide the same function as strut <bean:write>?
    Thanks and regards,
    Chin Tat

    ok i am not a struts programmer but from a quick search i am assuming <bean:write> outputs in html the value of a property in your java bean?
    if this is the case then you simply use
    #{beanName.propertyName}
    i.e
    <h:outputText value="#{beanName.propertyName}"/>
    note your bean will have to be registered in you facesContext as a managed bean to do this (where beanName is the name of your managedBean)
    if bean:write doesn't do this sorry :) forget my answer

  • Problem with logic:equal tag when used with bean:write

    Hi All,
    I have a problem with logic:equal.When i tried to use the following piece of code its not working
    <logic:equal name="var in session" value="<bean:write name='var in request'/>">
    Do some thing
    </logic:equal>
    its not working i know we cant use nested tags
    is thr any alternative instead of using a scriplet

    A scriptlet expression is about all you can do.
    <bean:define id="tempVar" name="var in request"/>
    <logic:equal name="var in session" value="<%= tempVar %>">
    ...If you have a JSP2.0 container with EL enabled, then you could use an EL expression instead of the standard <%= expr %>

  • 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

  • Jsp bean write nesting

    Hi,
    I am using struts...
    In my jsp I have an set of objects which i itrerate through and display the parameters in that object1..
    But the object1 has internally another object2 which has some parameters in it..
    while displaying the set of object1s i have to display parameter in object2.
    How can i do this ..can any body help...

    <logic:notEmpty name="alertForm" property="alerts">
         <logic:iterate id="alert" name="alertForm" property="alerts">
              <tr>
                   <td>
                   <div align="center"><bean:write name="alert" property="alertLocalTime"/></div>
              </td>
              <td>
                   <div align="center"><bean:write name="alert" property="segmentSN"/></div>
              </td>
              <td>
                   <div align="center"><bean:write name="alert" property="alertAsTag"/></div>
              </td>
    </tr>
         </logic:iterate>
         </logic:notEmpty>
    </table>
    Here in alert bean i have another object ' WorkStatus ' which has members like statusCode, name etc..
    i have to print WorkStatus.statusCode in the above iterator loop..
    Can you suggest how i can do this..

Maybe you are looking for

  • SQL Server Compact 3.5 Merge Replication With SQL Server 2012 - Causing IIS App Pool to Crash

    Hi, I may be the only person in the world doing this but I wanted to give this information to anyone else who may follow this path in the future, and hopefully avoid a headache, or at least a paid support call to Microsoft. My original scenario was w

  • Can i re download music etc purchased on my account?

    My daughters ipod broke and has been replaced with a new one. Also, her itunes was on a laptop that too is not accessible. She has a new laptop and new ipod. All purchased downloads were made on my account. Can she re download them? I have searched p

  • MSI 9800pro and Dell 2001FP

    It's just great combo anyone looking for a great LCD for gaming you should give   the Dell 2001FP 20" lcd a try I have one and so far its all I hoped for nice clear text rich colors I use to use a Mitsub 21" crt I would never go back to a crt. I use

  • Text srv malware from downloads for mac

    Hello, I have a Mac, ibook G4. Since this is pre-intel, i have to use Adoble Flash version 10.1 I've downloaded 2 different files from Adobe for Flaxh 10.1, included one called "debugger versions". Both of these files have contained the text srv malw

  • Two USB 3.0 PCI-E cards?

    I first installed a generic USB 3.0 card. Works great. Now I installed a 2nd one(an ASUS U3S6). This one works great but the 1st card doesn't work any more. Is something wrong or can I only have one USB 3.0 card? (latest NEC USB 3.0 Host Controller d