FormTag.java 文件源码

java
阅读 34 收藏 0 点赞 0 评论 0

项目:jaffa-framework 作者:
/** Get the HTML id for the form. This is based on the application rule
 * "jaffa.widgets.form.idFormat" which can have the following values
 * <ul>
 * <li>none - No id will be used for the form
 * <li>formname - The struts form name will be used
 * <li>index - an index value, based on the number of forms on the page will be used.
 * The value will be prefixed with 'j', so the first form will be id='j0'
 * <li>class - Will used the classname of the formbean (without the package name) for the id
 * </ul>
 * Older version of JAFFA used the equivilent of 'formname' which is the default if nothing is set.
 */
public String getHtmlIdPrefix() {
    if(m_htmlName!=null) {
        m_htmlIdPrefix=m_htmlName;
    } else if(m_htmlIdPrefix==null) {
        if(ID_FORMAT_INDEX.equals(m_idFormat)) {
            //Look for a index counter in the request
            Integer index = (Integer)pageContext.getAttribute(FORM_TAG_INDEX,PageContext.REQUEST_SCOPE);
            if(index==null)
                index=new Integer(1);
            m_htmlIdPrefix="j" + index;
            pageContext.setAttribute(FORM_TAG_INDEX,new Integer(index.intValue()+1),PageContext.REQUEST_SCOPE);
        } else if(ID_FORMAT_NONE.equals(m_idFormat))
            // use no id
            m_htmlIdPrefix="";
        else if(ID_FORMAT_CLASS.equals(m_idFormat)) {
            // Use the class name (exclude the package)
            m_htmlIdPrefix=StringHelper.getShortClassName(FormTag.class);
        } else {
            // Default to original behavior, and use the struts Bean name
            m_htmlIdPrefix=getBeanName();
        }
    }
    return m_htmlIdPrefix;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号