Stuart Guthrie <[EMAIL PROTECTED]> wrote on 08/16/2004 10:01:49 AM:
> Hi there,
>
> What I'm trying to do is re-use the same jsp for ADD/UPDATE modes. In
> order to do this, certain field attributes will be different depending
> on the modes and sometimes even on the user's security credentials or
> the 'status' of the customer row.
>
> To this end I need to pass in the form bean whether a particular field
> is disabled or not
>
> I've searched the archives to no avail. I'm trying to set the disable=''
> attribute on the html:text tag to a value in the form bean I'm passing
> in.
>
> eg:
>
> formbean.isCustomerCodeEnabled()
>
> returns a boolean true/false
>
> formbean.getCustomerCode()
>
> is the value of customer code.
>
> I'm trying (hoping) to do something like this:
>
> <html:text property="customerCode" maxlength="8"size="8"
> disable="!CustomerCodeEnabled" />
>
> I've tried lots of different approaches, all failing. I've also scanned
> the examples to no avail.
>
> Latest attempt is:
>
> <bean:define id="customerCodeEnabled"
> name="CustomerFormWindowMainTabActionForm"
> property="CustomerCodeEnabled"
> type="boolean" value="true"/>
>
> <% boolean customerCodeDisabled=(!customerCodeEnabled); %>
> <TD><html:text property="customerCode" maxlength="8"size="8"
> disabled="<%=customerCodeDisabled%>" /></TD>
Does this work for you?
<html:text property="customerCode" maxlength="8" size="8"
disable="isCustomerCodeEnabled" />
I had an app with similar requirements. IIRC, I solved it by doing the
following.
In the JSP first define the FormBean that contains the boolean values:
<bean:define name="SomeForm" id="form"
type="com.myCompany.MyFormBeanClass" />
then access the boolean fields for each form field like so:
<html:text property="description" maxlength="79" size="60" readonly="<%=
form.isDescriptionDisabled() %>" />
Hope that helps.
Susan Bradeen
>
> Which fails with:
>
> customerCodeEnabled = null; [javac] ^ An error occurred at line: 87 in
> the jsp file: /CustomerFormWindowMainTabBody.jsp Generated servlet
> error:
> [javac]/home/sfg/javadev/jboss-3.2.
>
3/server/default/work/MainEngine/localhost/pimsweb/CustomerFormWindowMainTabBody_jsp.
> java:175: inconvertible types
> [javac] found : java.lang.Object [javac] required: boolean [javac]
> customerCodeEnabled = (boolean)
> pageContext.findAttribute("customerCodeEnabled"); [javac] ^ [javac] 2
> errors '
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
_____________________________________________________________________________
> Scanned for SoftLanding Systems, Inc. by IBM Email Security
> Management Services powered by MessageLabs.
>
_____________________________________________________________________________
_____________________________________________________________________________
Scanned for SoftLanding Systems, Inc. by IBM Email Security Management Services
powered by MessageLabs.
_____________________________________________________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]