In my Application i'm using Spring Supplied tags...
<%@ taglib prefix="form" uri=""%>
<%@ taglib prefix="c" uri=""%>
<fieldset id="user1">
<form:form action="frm1" modelAttribute="SUPER" >
------
------
</form:form>
</fieldset>
And My Requirement is basically Form is only Read only when we click Edit button of the form then only form will change Editable mode.
I'm trying readonly
Property but not work .. i think this property for html.
Please give me suggestion how to do this in any java related technology.. Like javascript and JQuery.
In my Application i'm using Spring Supplied tags...
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<fieldset id="user1">
<form:form action="frm1" modelAttribute="SUPER" >
------
------
</form:form>
</fieldset>
And My Requirement is basically Form is only Read only when we click Edit button of the form then only form will change Editable mode.
I'm trying readonly
Property but not work .. i think this property for html.
Please give me suggestion how to do this in any java related technology.. Like javascript and JQuery.
Share Improve this question asked Apr 8, 2013 at 9:09 Java DeveloperJava Developer 1,9019 gold badges32 silver badges63 bronze badges2 Answers
Reset to default 16The type of readonly
property is Boolean, so it should be readonly="true"
:
<form:input path="firstName" class="form-control"
placeholder="First Name" type="text" readonly="true"/>
You can use c tag library to assign the values to your inputs from your model while using readonly="readonly" property.
<form:form id="simpleDomainForm" modelAttribute="simpleDomain">
<input name="modelId" value='<c:out value="${simpleDomain.modelId}"></c:out>' readonly="readonly" class="required">
<input name="modelName" value='<c:out value="${simpleDomain.modelName}"></c:out>' readonly="readonly" class="required">
<input type="button" value="Toggle" onclick="toggleForm();">
</form:form>
And jQuery you can enable these input boxes on click event of Edit button. Following is a simple example of script using jQuery to toggle readonly state of inputs.
[Note: This is just a simple example, you need to customize it according to your requirement]
<script>
function toggleForm(){
if($("#simpleDomainForm").children(".required").attr("readonly") == "readonly")
$("#simpleDomainForm").children(".required").removeAttr("readonly");
else
$("#simpleDomainForm").children(".required").attr("readonly", "readonly");
}
</script>