<input type="submit" value="Save" id="entryEdit_saveDraft"
name="entryEdit!saveDraft"/>
I guess what we want.
###
In the FormButton populateComponentHtmlId(Form form) it evaluates the action based on the text
rather than the "actual" action. If the action is determined from the mapping it renders
correctly. See "// determine actual action" in code below
<s:set var="mainAction">entryEdit</s:set>
<s:submit value="Save as Draft" action="%{#mainAction}!saveDraft"/>
renders:
<input type="submit" value="Save as Draft" id="entry____mainAction__saveDraft"
name="action:entryAdd!saveDraft">
#####
org.apache.struts2.components.FormButton
protected void populateComponentHtmlId(Form form) {
String _tmp_id = "";
if (id != null) {
// this check is needed for backwards compatibility with 2.1.x
_tmp_id = findString(id);
} else {
if (form != null && form.getParameters().get("id") != null) {
_tmp_id = _tmp_id + form.getParameters().get("id").toString() +
"_";
}
if (name != null) {
_tmp_id = _tmp_id + escape(name);
} else if (action != null || method != null) {
if (action != null) {
//_tmp_id = _tmp_id + escape(tmp);
// determine actual action
ActionMapping mapping = new ActionMapping();
mapping.setName(findString(action));
if (method != null) {
mapping.setMethod(findString(method));
}
mapping.setExtension("");
String tmp = actionMapper.getUriFromActionMapping(mapping);
_tmp_id = _tmp_id + escape(tmp);
}
//if (method != null) {
// _tmp_id = _tmp_id + "_" + escape(method);
//}
} else {
// if form is null, this component is used, without a form, i
guess
// there's not much we could do then.
if (form != null) {
_tmp_id = _tmp_id + form.getSequence();
}
}
}
addParameter("id", _tmp_id);
addParameter("escapedId", escape(_tmp_id));
}
On 08/04/2023 20:00, Lukasz Lenart wrote:
What about such an approach?
<input type="submit" value="Save" id="entryEdit_saveDraft"
name="entryEdit!saveDraft"/>
The ID is generated based on the evaluated version of the name attribute.
Regards
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]