當前位置: 首頁>>代碼示例>>Java>>正文


Java ActionSupport類代碼示例

本文整理匯總了Java中com.opensymphony.xwork2.ActionSupport的典型用法代碼示例。如果您正苦於以下問題:Java ActionSupport類的具體用法?Java ActionSupport怎麽用?Java ActionSupport使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ActionSupport類屬於com.opensymphony.xwork2包,在下文中一共展示了ActionSupport類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testUpload

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
@Test
public void testUpload() throws Exception {
    File file = File.createTempFile("tmp", NON_ZIP_EXTENSION);

    List<File> files = new ArrayList<File>();
    List<String> fileNames = new ArrayList<String>();
    files.add(file);
    fileNames.add(file.getName());
    action.setUpload(files);
    action.setUploadFileName(fileNames);

    MockHttpServletResponse response = new MockHttpServletResponse();
    ServletActionContext.setResponse(response);

    assertEquals(ActionSupport.NONE, action.upload());
    JSONArray jsonResult = JSONArray.fromObject(response.getContentAsString());
    assertEquals(1, jsonResult.size());
    JSONObject map = jsonResult.getJSONObject(0);
    assertEquals(2, map.keySet().size());
    assertTrue(map.get("name").toString().contains(NON_ZIP_EXTENSION));
}
 
開發者ID:NCIP,項目名稱:caarray,代碼行數:22,代碼來源:UploadProjectFilesActionTest.java

示例2: testUpload_UnexpectedError

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
@Test
public void testUpload_UnexpectedError() throws Exception {
    String uploadingErrorKey = UploadProjectFilesAction.UPLOADING_ERROR_KEY;
    File file = File.createTempFile("tmp", ZIP_EXTENSION);

    List<File> files = Lists.newArrayList(file);
    List<String> uploadFileNames = Lists.newArrayList(file.getName());
    action.setUpload(files);
    action.setUploadFileName(uploadFileNames);

    when(
            mockUploadUtils.uploadFiles(any(Project.class), anyListOf(FileWrapper.class))).thenThrow(new IllegalStateException());

    MockHttpServletResponse response = new MockHttpServletResponse();
    ServletActionContext.setResponse(response);

    assertEquals(ActionSupport.NONE, action.upload());
    JSONArray jsonResult = JSONArray.fromObject(response.getContentAsString());
    assertEquals(1, jsonResult.size());
    JSONObject map = jsonResult.getJSONObject(0);
    assertEquals(2, map.keySet().size());
    assertTrue(map.get("name").toString().contains(ZIP_EXTENSION));

    assertTrue(map.get("error").toString(), map.get("error").toString().contains(uploadingErrorKey));
}
 
開發者ID:NCIP,項目名稱:caarray,代碼行數:26,代碼來源:UploadProjectFilesActionTest.java

示例3: newOwner

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
@Test
public void newOwner() {
    OwnershipAction action  = new OwnershipAction();
    String ret = action.newOwner();
    assertEquals("assets", ret);


    action.setGroupIds(Arrays.asList(1L, 2L, 3L));
    action.setProjectIds(Arrays.asList(1L, 2L, 3L));
    User owner = new User();
    owner.setUserId(1L);
    action.setTargetUser(owner);

    ret = action.newOwner();
    assertEquals(ActionSupport.SUCCESS, ret);
}
 
開發者ID:NCIP,項目名稱:caarray,代碼行數:17,代碼來源:OwnershipActionTest.java

示例4: findField

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
/**
 * Tries to find field by name in given class or it super classes up to
 * (excluded) ActionSupport or Object.
 * 
 * @param clazz
 *            Class to start searching a field from.
 * @param fieldName
 *            Name of the field to search.
 * @return Field instance or <code>null</code> if no such field is found.
 */
Field findField(Class<?> clazz, final String fieldName) {
    Field field = null;
    if (clazz != null && fieldName != null) {
        do {
            try {
                field = clazz.getDeclaredField(fieldName);
            } catch (NoSuchFieldException nsfe) {
                if (LOG.isTraceEnabled()) {
                    LOG.trace("In findField", nsfe);
                }
            }
            clazz = clazz.getSuperclass();
        } while (clazz != ActionSupport.class && clazz != Object.class
                && clazz != null && field == null);
    }
    return field;
}
 
開發者ID:aleksandr-m,項目名稱:struts2-actionflow,代碼行數:28,代碼來源:ActionFlowConfigBuilder.java

示例5: testCreatePlot

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
@Test
public void testCreatePlot() throws Exception {
    setupActionVariables();
    assertEquals(ActionSupport.SUCCESS, action.createPlot());
    action.setCreatePlotSelected(true);
    assertEquals(ActionSupport.INPUT, action.createPlot());
    action.getKmPlotParameters().setSurvivalValueDefinition(new SurvivalValueDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().setId(Long.valueOf(1));
    action.getKmPlotParameters().getSurvivalValueDefinition().setSurvivalStartDate(new AnnotationDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().getSurvivalStartDate().setDataType(AnnotationTypeEnum.DATE);
    action.getKmPlotParameters().getSurvivalValueDefinition().setDeathDate(new AnnotationDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().getDeathDate().setDataType(AnnotationTypeEnum.DATE);
    action.getKmPlotParameters().getSurvivalValueDefinition().setLastFollowupDate(new AnnotationDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().getLastFollowupDate().setDataType(AnnotationTypeEnum.DATE);
    assertEquals(ActionSupport.SUCCESS, action.createPlot());
    verify(analysisService, times(1)).createKMPlot(any(StudySubscription.class), any(AbstractKMParameters.class));
    assertTrue(action.isCreatable());
}
 
開發者ID:NCIP,項目名稱:caintegrator,代碼行數:19,代碼來源:KMPlotQueryBasedActionTest.java

示例6: testCreatePlot

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
@Test
public void testCreatePlot() throws Exception {
    setupActionVariables();
    assertEquals(ActionSupport.SUCCESS, action.createPlot());
    action.setCreatePlotSelected(true);
    assertEquals(ActionSupport.INPUT, action.createPlot());
    action.getKmPlotParameters().setSurvivalValueDefinition(new SurvivalValueDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().setId(Long.valueOf(1));
    action.getKmPlotParameters().getSurvivalValueDefinition().setSurvivalStartDate(new AnnotationDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().getSurvivalStartDate().setDataType(AnnotationTypeEnum.DATE);
    action.getKmPlotParameters().getSurvivalValueDefinition().setDeathDate(new AnnotationDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().getDeathDate().setDataType(AnnotationTypeEnum.DATE);
    action.getKmPlotParameters().getSurvivalValueDefinition().setLastFollowupDate(new AnnotationDefinition());
    action.getKmPlotParameters().getSurvivalValueDefinition().getLastFollowupDate().setDataType(AnnotationTypeEnum.DATE);
    action.getKmPlotParameters().setControlSampleSetName("controls");
    assertEquals(ActionSupport.SUCCESS, action.createPlot());
    verify(analysisService, atLeastOnce()).createKMPlot(any(StudySubscription.class), any(AbstractKMParameters.class));

    assertTrue(action.isCreatable());
}
 
開發者ID:NCIP,項目名稱:caintegrator,代碼行數:21,代碼來源:KMPlotGeneExpressionBasedActionTest.java

示例7: testCreatePlot

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
@Test
public void testCreatePlot() throws Exception {
    setupActionVariables();
    assertEquals(ActionSupport.SUCCESS, action.createPlot());
    action.setCreatePlotSelected(true);
    assertEquals(ActionSupport.INPUT, action.createPlot());
    action.getPlotParameters().getSelectedValues().clear();
    action.getPlotParameters().getSelectedValues().add(val1);
    action.getPlotParameters().getSelectedValues().add(val2);
    assertEquals(ActionSupport.INPUT, action.createPlot());
    action.getPlotParameters().setGeneSymbol("EGFR");
    assertEquals(ActionSupport.SUCCESS, action.createPlot());
    verify(analysisService, atLeastOnce()).createGeneExpressionPlot(any(StudySubscription.class),
            any(AbstractGEPlotParameters.class));
    assertFalse(action.isCreatable());

    action.getGePlotForm().getAnnotationBasedForm().setSelectedAnnotationId("1");
    action.getGePlotForm().getAnnotationBasedForm().setAnnotationGroupSelection("subjectAnnotations");
    assertTrue(action.isCreatable());
}
 
開發者ID:NCIP,項目名稱:caintegrator,代碼行數:21,代碼來源:GEPlotAnnotationBasedActionTest.java

示例8: handleErrorData

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
/**
 * Injects the errors in the action using the ErrorData object from the list
 * @param errorData
 * @param action
 */
public static void handleErrorData(ErrorData errorData, ActionSupport action){
	String fieldName=errorData.getFieldName();
	if (fieldName==null) {
		action.addActionError(createMessage(errorData, action));
	} else {			   
		action.addFieldError(fieldName,createMessage(errorData, action));
	}
	
}
 
開發者ID:trackplus,項目名稱:Genji,代碼行數:15,代碼來源:ErrorHandlerStruts2Adapter.java

示例9: createMessage

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
/**
 * Gets a localized message with no- or more (localized or not localized) parameters  
 * @param errorData
 * @param action
 * @return
 */
private static String createMessage(ErrorData errorData, ActionSupport action){
	String key=errorData.getResourceKey();
	List<Object> params=new LinkedList<Object>();
	if(errorData.getResourceParameters()!=null) {
		for (ErrorParameter parameter : errorData.getResourceParameters()) {
			if(parameter.isResource()){
				params.add(action.getText(parameter.getParameterValue()+""));
			}else{
				params.add(parameter.getParameterValue());
			}
		}
	}
	return action.getText(key, params);
}
 
開發者ID:trackplus,項目名稱:Genji,代碼行數:21,代碼來源:ErrorHandlerStruts2Adapter.java

示例10: testHelloWorld

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
public void testHelloWorld() throws Exception {
    HelloWorld hello_world = new HelloWorld();
    String result = hello_world.execute();
    assertTrue("Expected a success result!",
            ActionSupport.SUCCESS.equals(result));
    assertTrue("Expected the default message!",
            hello_world.getText(HelloWorld.MESSAGE).equals(hello_world.getMessage()));
}
 
開發者ID:wisthy,項目名稱:BeeBreedingManager,代碼行數:9,代碼來源:HelloWorldTest.java

示例11: addFieldErrors

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
public void addFieldErrors(ActionSupport actionAs,
		Collection invalidValuesFromRequest) {
	for (ConstraintViolation constraintViolation : (List<ConstraintViolation>)invalidValuesFromRequest) {
		StringBuilder sbMessage = new StringBuilder(actionAs.getText(constraintViolation.getPropertyPath().toString(),""));
		if (sbMessage.length()>0)
			sbMessage.append(" - ");
		sbMessage.append(actionAs.getText(constraintViolation.getMessage()));
		actionAs.addFieldError(constraintViolation.getPropertyPath().toString(), sbMessage.toString());
	}
}
 
開發者ID:javalover123,項目名稱:full-hibernate-plugin-for-struts2,代碼行數:11,代碼來源:Struts2HibernateValidatorV402.java

示例12: doInvalidFileExceptionTest

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
private void doInvalidFileExceptionTest(String expectedErrorKey, boolean unpackSelected) throws Exception {
    String errorKey = "key";
    String errorMessage = "message";
    String errorUnpackingZipKey = "errors.unpackingErrorWithZip";
    File file = File.createTempFile("tmp", ZIP_EXTENSION);

    List<File> files = Lists.newArrayList(file);
    List<String> uploadFileNames = Lists.newArrayList(file.getName());
    action.setUpload(files);
    action.setUploadFileName(uploadFileNames);

    if (unpackSelected) {
        action.setSelectedFilesToUnpack(Lists.newArrayList(file.getName()));
    }

    when(
            mockUploadUtils.uploadFiles(any(Project.class), anyListOf(FileWrapper.class))).thenThrow(
            new InvalidFileException(file.getName(), errorKey, errorMessage));

    MockHttpServletResponse response = new MockHttpServletResponse();
    ServletActionContext.setResponse(response);

    assertEquals(ActionSupport.NONE, action.upload());
    JSONArray jsonResult = JSONArray.fromObject(response.getContentAsString());
    assertEquals(1, jsonResult.size());
    JSONObject map = jsonResult.getJSONObject(0);
    assertEquals(2, map.keySet().size());
    assertTrue(map.get("name").toString().contains(ZIP_EXTENSION));

    assertTrue(map.get("error").toString(), map.get("error").toString().contains(expectedErrorKey));
}
 
開發者ID:NCIP,項目名稱:caarray,代碼行數:32,代碼來源:UploadProjectFilesActionTest.java

示例13: testPartialUploadCheck

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
@Test
public void testPartialUploadCheck() throws Exception {
    action.setChunkedFileName("testfile");
    action.setChunkedFileSize(1234L);
    CaArrayFile file = new CaArrayFile();
    file.setPartialSize(111L);
    when(fileDao.getPartialFile(anyLong(), eq("testfile"), eq(1234L))).thenReturn(file);
    MockHttpServletResponse response = new MockHttpServletResponse();
    ServletActionContext.setResponse(response);
    assertEquals(ActionSupport.NONE, action.partialUploadCheck());
    JSONObject asdf = JSONObject.fromObject(response.getContentAsString());
    assertEquals(111L, asdf.getLong("size"));
}
 
開發者ID:NCIP,項目名稱:caarray,代碼行數:14,代碼來源:UploadProjectFilesActionTest.java

示例14: testUploadMessages

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
@Test
public void testUploadMessages() throws Exception {
    File file = File.createTempFile("tmp", NON_ZIP_EXTENSION);
    List<File> files = new ArrayList<File>();
    List<String> fileNames = new ArrayList<String>();
    files.add(file);
    fileNames.add(file.getName());
    action.setUpload(files);
    action.setUploadFileName(fileNames);

    // Upload a file and check for success message
    FileProcessingResult result = new FileProcessingResult();
    result.addSuccessfulFile(file.getName());
    when(mockUploadUtils.uploadFiles(any(Project.class), anyListOf(FileWrapper.class))).thenReturn(result);
    assertEquals(ActionSupport.NONE, action.upload());
    List<String> msgs = ActionHelper.getMessages();
    assertEquals(1, msgs.size());
    assertEquals(1 + UploadProjectFilesAction.FILE_UPLOADED_MSG_SUFFIX, msgs.get(0));

    // Upload a second file and check for updated success message
    FileProcessingResult result2 = new FileProcessingResult();
    result2.addSuccessfulFile("file2");
    when(mockUploadUtils.uploadFiles(any(Project.class), anyListOf(FileWrapper.class))).thenReturn(result2);
    assertEquals(ActionSupport.NONE, action.upload());
    msgs = ActionHelper.getMessages();
    assertEquals(1, msgs.size());
    assertEquals(2 + UploadProjectFilesAction.FILE_UPLOADED_MSG_SUFFIX, msgs.get(0));
}
 
開發者ID:NCIP,項目名稱:caarray,代碼行數:29,代碼來源:UploadProjectFilesActionTest.java

示例15: testDownloadDicomFile

import com.opensymphony.xwork2.ActionSupport; //導入依賴的package包/類
@Test
public void testDownloadDicomFile() {
    NCIADicomJob dicomJob = new NCIADicomJob();
    assertEquals(ActionSupport.ERROR, nciaRetrievalAction.downloadDicomFile());
    dicomJob.setCompleted(true);
    dicomJob.setDicomFile(TestDataFiles.VALID_FILE);
    SessionHelper.getInstance().getDisplayableUserWorkspace().setDicomJob(dicomJob);
    assertEquals("dicomFileResult", nciaRetrievalAction.downloadDicomFile());
}
 
開發者ID:NCIP,項目名稱:caintegrator,代碼行數:10,代碼來源:NCIADicomRetrievalActionTest.java


注:本文中的com.opensymphony.xwork2.ActionSupport類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。