我做了什么:
步骤1:我在“Test”创作模板中创建了两个文本元素(比如元素的名称是userName和UserId)。 第2步:我使用jsp。
自定义了第一个元素(userName)但是在自定义第一个元素(userName)时,我需要将第二个文本元素(UserId)值提取到userName中。
我可以通过使用下面的代码来获取第一个Text元素(UserName)的值,但是我将如何获得第二个元素值?
<%@ taglib uri="/WEB-INF/tld/portlet.tld" prefix="portletAPI" %>
<%@ page import="com.ibm.workplace.wcm.api.authoring.CustomItemBean" %>
<portletAPI:init />
<%
CustomItemBean customItem =
(CustomItemBean) request.getAttribute("CustomItemBean");
customItem.setSubmitFunctionName("myoptionsubmit");
String fvalue = (String)customItem.getFieldValue();
%>
<script language='Javascript'>
function myoptionsubmit()
{
document.getElementById('<%=customItem.getFieldName()%>').value =
document.getElementById('<%=customItem.getFieldName()%>_mycustomoption').value;
}
</script>
<INPUT id='<%=customItem.getFieldName()%>_mycustomoption' value="<%=fvalue%>">
答案 0 :(得分:0)
<%@ page import="com.ibm.workplace.wcm.api.*"%>
<%@ page import="com.ibm.workplace.wcm.api.exceptions.*"%>
<%@ page import="java.util.*,javax.servlet.jsp.JspWriter,java.io.*"%>
<%
Workspace myworkspace=null;
try {
DocumentId docId=null;
DocumentIdIterator itemsIterator=null;
myworkspace = WCM_API.getRepository().getSystemWorkspace();
DocumentLibrary MyLibrary = myworkspace.getDocumentLibrary("LIB_FOR_DEVICE");
DocumentIdIterator docIdIterator = myworkspace.findByName(DocumentTypes.Content, "RENDER_TEST_CONTENT");
DocumentId docId1;
Content currentContent;
LibraryRichTextComponent currentContent1;
Object object=null;
TextComponent textComponent=null;
RichTextComponent richTextComponent=null;
ImageComponent imageComponent=null;
while(docIdIterator.hasNext())
{
docId1 = (DocumentId)docIdIterator.next();
currentContent = (Content)myworkspace.getById(docId1);
ContentComponentIterator contentComponentIterator=currentContent.componentIterator();
while(contentComponentIterator.hasNext())
{
object=contentComponentIterator.next();
if(object instanceof TextComponent)
{
textComponent=(TextComponent)object;
out.println("<br/>TC:</br>"+ textComponent.getText());
}
if(object instanceof RichTextComponent)
{
richTextComponent=(RichTextComponent)object;
out.println("<br/>RTC:</br>"+ richTextComponent.getRichText());
}
}
}
myworkspace.logout();
} catch(例外e) {} %GT;